Dictionary

The Dictionary provides read access to a singkle keyvi file.

from keyvi.dictionary import Dictionary

d=Dictionary("data.kv")
class keyvi.dictionary.Dictionary

Cython implementation of _Dictionary

Keyvi dictionary, an immutable containers storing key value pairs, optimized for size, lookup performance and special lookp use cases. A keyvi dictionary has to be created by a previous compile run.

Keyvi dictionaries allow multiple types of approximate and completion matches due to its internal FST based data structure.

complete_fuzzy_multiword()

Overload:

complete_fuzzy_multiword(self, key: bytes | str, max_edit_distance: int) Any

Complete the given key to full matches after whitespace tokenizing, allowing up to max_edit_distance distance(Levenshtein). In case the used dictionary supports inner weights, the completer traverses the dictionary according to weights, otherwise byte-order.

Overload:

complete_fuzzy_multiword(self, key: bytes | str, max_edit_distance: int, minimum_exact_prefix: int) Any

Complete the given key to full matches after whitespace tokenizing, allowing up to max_edit_distance distance(Levenshtein) except for a given exaxt prefix which must match exaxt. In case the used dictionary supports inner weights, the completer traverses the dictionary according to weights, otherwise byte-order.

complete_multiword()

Overload:

complete_multiword(self, key: bytes | str) Any

Complete the given key to full matches after whitespace tokenizing. In case the used dictionary supports inner weights, the completer traverses the dictionary according to weights, otherwise byte-order.

Overload:

complete_multiword(self, key: bytes | str, top_n: int) Any

Complete the given key to full matches after whitespace tokenizing and return the top n completions. In case the used dictionary supports inner weights, the completer traverses the dictionary according to weights, otherwise byte-order.

Note, due to depth-first traversal the traverser immediately yields results when it visits them. The results are neither in order nor limited to n. It is up to the caller to resort and truncate the lists of results. Only the number of top completions is guaranteed.

complete_prefix()

Overload:

complete_prefix(self, key: bytes | str) Any

Complete the given key to full matches(prefix matching) In case the used dictionary supports inner weights, the completer traverses the dictionary according to weights, otherwise byte-order.

Overload:

complete_prefix(self, key: bytes | str, top_n: int) Any

Complete the given key to full matches(prefix matching) and return the top n completions. In case the used dictionary supports inner weights, the completer traverses the dictionary according to weights, otherwise byte-order.

Note, due to depth-first traversal the traverser immediately yields results when it visits them. The results are neither in order nor limited to n. It is up to the caller to resort and truncate the lists of results. Only the number of top completions is guaranteed.

manifest(self) str
match(self, key: bytes | str) Any
match_fuzzy()

Overload:

match_fuzzy(self, key: bytes | str, max_edit_distance: int) Any

Overload:

match_fuzzy(self, key: bytes | str, max_edit_distance: int, minimum_exact_prefix: int) Any
match_near()

Overload:

match_near(self, key: bytes | str, minimum_prefix_length: int) Any

Overload:

match_near(self, key: bytes | str, minimum_prefix_length: int, greedy: bool) Any
search(self, key: bytes | str) Any
search_tokenized(self, text: bytes | str) Any