search method
Searches facts whose content contains query tokens.
Implementation
List<Memory> search(String query, {int maxResults = 10}) {
final tokens = _tokenise(query);
final scored = <MapEntry<SemanticFact, double>>[];
for (final fact in _byId.values) {
final score = _scoreFact(fact, tokens);
if (score > 0) scored.add(MapEntry(fact, score));
}
scored.sort((a, b) => b.value.compareTo(a.value));
return scored.take(maxResults).map((e) {
final f = e.key;
return Memory(
id: f.id,
content: f.statement,
type: MemoryType.semantic,
strength: f.confidence,
);
}).toList();
}