-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
access simplemma functionality only via annif.simplemma_util
- Loading branch information
Showing
4 changed files
with
20 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
"""Wrapper code for using Simplemma functionality in Annif""" | ||
|
||
from simplemma import LanguageDetector, Lemmatizer | ||
from simplemma.strategies import DefaultStrategy | ||
from simplemma.strategies.dictionaries import DefaultDictionaryFactory | ||
|
||
LANG_CACHE_SIZE = 5 # How many language dictionaries to keep in memory at once (max) | ||
|
||
_dictionary_factory = DefaultDictionaryFactory(cache_max_size=LANG_CACHE_SIZE) | ||
_lemmatization_strategy = DefaultStrategy(dictionary_factory=_dictionary_factory) | ||
lemmatizer = Lemmatizer(lemmatization_strategy=_lemmatization_strategy) | ||
|
||
|
||
def get_language_detector(lang: str) -> LanguageDetector: | ||
return LanguageDetector(lang, lemmatization_strategy=_lemmatization_strategy) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters