Skip to content

Commit

Permalink
Merge pull request #594 from NatLibFi/upgrade-simplemma-0.7
Browse files Browse the repository at this point in the history
Upgrade Simplemma to version 0.7
  • Loading branch information
osma authored Jun 23, 2022
2 parents 8702efb + add4b19 commit aa50441
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 17 deletions.
11 changes: 1 addition & 10 deletions annif/analyzer/simplemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,8 @@ class SimplemmaAnalyzer(analyzer.Analyzer):

def __init__(self, param, **kwargs):
self.lang = param
self.langdata = None
super().__init__(**kwargs)

def __getstate__(self):
"""Return the state of the object for pickling purposes. The langdata
field is set to None as it's more efficient to use load_data."""

return {'lang': self.lang, 'langdata': None}

@functools.lru_cache(maxsize=500000)
def _normalize_word(self, word):
if self.langdata is None:
self.langdata = simplemma.load_data(self.lang)
return simplemma.lemmatize(word, self.langdata)
return simplemma.lemmatize(word, self.lang)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def read(fname):
'stwfsapy==0.3.*',
'python-dateutil',
'tomli==2.0.*',
'simplemma==0.6.*'
'simplemma==0.7.*'
],
tests_require=['py', 'pytest', 'requests'],
extras_require={
Expand Down
6 changes: 0 additions & 6 deletions tests/test_analyzer_simplemma.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@
simplemma = pytest.importorskip("annif.analyzer.simplemma")


def test_simplemma_getstate():
analyzer = annif.analyzer.get_analyzer("simplemma(fi)")
state = analyzer.__getstate__()
assert state == {'lang': 'fi', 'langdata': None}


def test_simplemma_finnish_analyzer_normalize_word():
analyzer = annif.analyzer.get_analyzer("simplemma(fi)")
assert analyzer._normalize_word("xyzzy") == "xyzzy"
Expand Down

0 comments on commit aa50441

Please sign in to comment.