mirror of https://github.com/explosion/spaCy.git
Fix circular import in lemmatizer
This commit is contained in:
parent
dec5571bf3
commit
ed2b106f4d
|
@ -4,7 +4,6 @@ import pathlib
|
||||||
|
|
||||||
import ujson as json
|
import ujson as json
|
||||||
|
|
||||||
from .en.lemmatizer import INDEX, EXC, RULES
|
|
||||||
from .symbols import POS, NOUN, VERB, ADJ, PUNCT
|
from .symbols import POS, NOUN, VERB, ADJ, PUNCT
|
||||||
from .symbols import VerbForm_inf, VerbForm_none
|
from .symbols import VerbForm_inf, VerbForm_none
|
||||||
from .symbols import Number_sing
|
from .symbols import Number_sing
|
||||||
|
@ -13,11 +12,8 @@ from .symbols import Degree_pos
|
||||||
|
|
||||||
class Lemmatizer(object):
|
class Lemmatizer(object):
|
||||||
@classmethod
|
@classmethod
|
||||||
def load(cls, path, rules=None):
|
def load(cls, path, index=None, exc=None, rules=None):
|
||||||
index = dict(INDEX)
|
return cls(index or {}, exc or {}, rules or {})
|
||||||
exc = dict(EXC)
|
|
||||||
rules = dict(RULES)
|
|
||||||
return cls(index, exc, rules)
|
|
||||||
|
|
||||||
def __init__(self, index, exceptions, rules):
|
def __init__(self, index, exceptions, rules):
|
||||||
self.index = index
|
self.index = index
|
||||||
|
@ -47,7 +43,6 @@ class Lemmatizer(object):
|
||||||
morphology = {} if morphology is None else morphology
|
morphology = {} if morphology is None else morphology
|
||||||
others = [key for key in morphology if key not in (POS, 'number', 'pos', 'verbform')]
|
others = [key for key in morphology if key not in (POS, 'number', 'pos', 'verbform')]
|
||||||
true_morph_key = morphology.get('morph', 0)
|
true_morph_key = morphology.get('morph', 0)
|
||||||
print(univ_pos, morphology)
|
|
||||||
if univ_pos == 'noun' and morphology.get('Number') == 'sing':
|
if univ_pos == 'noun' and morphology.get('Number') == 'sing':
|
||||||
return True
|
return True
|
||||||
elif univ_pos == 'verb' and morphology.get('VerbForm') == 'inf':
|
elif univ_pos == 'verb' and morphology.get('VerbForm') == 'inf':
|
||||||
|
|
Loading…
Reference in New Issue