Trie Dictionary Factory
Classes
TrieDictionaryFactory
Bases: DictionaryFactory
Memory optimized DictionaryFactory backed by MARISA-tries.
This dictionary factory creates dictionaries, which are backed by a MARISA-trie instead of a dict, to make them consume very little memory compared to the DefaultDictionaryFactory. Trade-offs are that lookup performance isn't as good as with dicts.
Source code in simplemma/strategies/dictionaries/trie_dictionary_factory.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
Functions
__init__(cache_max_size=8, use_disk_cache=True, disk_cache_dir=None)
Initialize the TrieDictionaryFactory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cache_max_size
|
int
|
The maximum number dictionaries to
keep in memory. Defaults to |
8
|
use_disk_cache
|
bool
|
Whether to cache the tries on disk to
speed up loading time. Defaults to |
True
|
disk_cache_dir
|
str | None
|
Path where the generated tries should be stored in. Defaults to a Simplemma- specific subdirectory of the user's cache directory. |
None
|
Source code in simplemma/strategies/dictionaries/trie_dictionary_factory.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 | |
get_dictionary(lang)
Retrieves a dictionary for the specified language.
Source code in simplemma/strategies/dictionaries/trie_dictionary_factory.py
128 129 130 131 132 133 | |
TrieWrapDict
Bases: MutableMapping[str, Any]
Wrapper around BytesTrie to make them behave like dicts.
Source code in simplemma/strategies/dictionaries/trie_dictionary_factory.py
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |