Skip to content

Commit

Permalink
set force=True on spacy extension to allow re-definition
Browse files Browse the repository at this point in the history
  • Loading branch information
bjascob committed Feb 3, 2020
1 parent 9365c63 commit 270983d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ build/
dist/
docs/build
pyinflect.egg-info/
.private/
2 changes: 1 addition & 1 deletion pyinflect/Inflections.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __init__(self, infl_fn, overrides_fn=None):
mv = min_version.split('.')
sv = spacy.__version__.split('.')
if sv[0] > mv[0] or (sv[0] == mv[0] and sv[1] >= mv[1]):
spacy.tokens.Token.set_extension('inflect', method=self.spacyGetInfl)
spacy.tokens.Token.set_extension('inflect', method=self.spacyGetInfl, force=True)
else:
logging.warning('Spacy extensions are disabled. Spacy version is %s. '
'A minimum of %s is required', spacy.__version__, min_version)
Expand Down
2 changes: 2 additions & 0 deletions tests/InflectionRulesTests.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,10 @@ def testGetInflection(self):
self.assertEqual(pyinflect.getInflection('xxdim', 'JJR', inflect_oov=True),
('xxdimer', 'xxdimmer'))

@unittest.skip("Skipping. SpaCy v2.2.3 lemmatizer error. Switch to Lemminflect to fix.")
def testSpacyGetInfl(self):
tokens = self.nlp('xxtest this')
self.assertEqual(tokens[0].lemma_, 'xxtest') # spacy lemmatizer error (spacy v2.2.3)
self.assertEqual(tokens[0]._.inflect('VBG', inflect_oov=False), None)
self.assertEqual(tokens[0]._.inflect('VBG', inflect_oov=True), 'xxtesting')

Expand Down

0 comments on commit 270983d

Please sign in to comment.