Completion

Standalone completion classes for more advanced completion use cases. For simple prefix completion, use keyvi.dictionary.Dictionary.complete_prefix() instead.

from keyvi.dictionary import Dictionary
from keyvi.completion import PrefixCompletion

d = Dictionary("completion.kv")
pc = PrefixCompletion(d)
for match in pc.complete("hel", 10):
    print(match.matched_string)
class keyvi.completion.PrefixCompletion

Completer for prefix-based queries, completing a given prefix to full keys in the dictionary.

Deprecated since version Use: dictionary.Dictionary.complete_prefix() instead.

complete(self: keyvi._core.completion.PrefixCompletion, query: str, number_of_results: SupportsInt | SupportsIndex = 10) → collections.abc.Iterator[keyvi._core.Match]

Get prefix completions for a query.

Returns an iterator of Match objects.

complete_fuzzy(self: keyvi._core.completion.PrefixCompletion, query: str, max_edit_distance: SupportsInt | SupportsIndex, minimum_exact_prefix: SupportsInt | SupportsIndex = 2) → collections.abc.Iterator[keyvi._core.Match]

Get fuzzy prefix completions for a query.

Returns an iterator of Match objects.

class keyvi.completion.MultiWordCompletion

Completer for multi-word queries, tokenizing on whitespace and completing the last token using the provided dictionary.

complete(self: keyvi._core.completion.MultiWordCompletion, query: str, number_of_results: SupportsInt | SupportsIndex = 10) → collections.abc.Iterator[keyvi._core.Match]

Get multi-word completions for a query.

Returns an iterator of Match objects.

class keyvi.completion.ForwardBackwardCompletion

Completer using a forward and backward dictionary to provide completions at any position within a key, not just at the end.

complete(self: keyvi._core.completion.ForwardBackwardCompletion, query: str, number_of_results: SupportsInt | SupportsIndex = 10) → collections.abc.Iterator[keyvi._core.Match]

Get forward-backward completions for a query.

Returns an iterator of Match objects.