Skip to content

Commit

Permalink
minor updates for spacy 3.x
Browse files Browse the repository at this point in the history
  • Loading branch information
bjascob committed Mar 10, 2021
1 parent 5194ef6 commit 86736be
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
4 changes: 2 additions & 2 deletions amrlib/graph_processing/annotator.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,11 @@ def _process_penman(pen, tokens=None):
pen.metadata['ner_iob'] = json.dumps([t.ent_iob_ for t in tokens])
pen.metadata['pos_tags'] = json.dumps([t.tag_ for t in tokens])
# Create lemmas
# SpaCy's lemmatizer returns -PRON- for pronouns so strip these
# The spaCy 2.0 lemmatizer returns -PRON- for pronouns so strip these (spaCy 3.x does not do this)
# Don't try to lemmatize any named-entities or proper nouns. Lower-case any other words.
lemmas = []
for t in tokens:
if t.lemma_ == '-PRON-':
if t.lemma_ == '-PRON-': # spaCy 2.x only
lemma = t.text.lower()
elif t.tag_.startswith('NNP') or t.ent_type_ not in ('', 'O'):
lemma = t.text
Expand Down
9 changes: 4 additions & 5 deletions req_tested_versions.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@
PyQt5 version: 5.15.0
graphviz version: 0.14.1
nltk version: 3.5
numpy version: 1.19.1
numpy version: 1.20.1
penman version: 1.1.0
requests version: 2.22.0
smatch version: 1.0.4
spacy version: 2.3.2
torch version: 1.7.0
spacy version: 3.0.5
torch version: 1.8.0
tqdm version: 4.48.2
transformers version: 4.0.0
transformers version: 4.2.2
unidecode version: 1.1.1
word2number version: 1.1

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
penman>=1.1.0
torch>=1.6
numpy
spacy>=2.0,<3.0 # also requires model download `python -m spacy download en_core_web_sm`
spacy>=2.0 # also requires model download `python -m spacy download en_core_web_sm`
tqdm
transformers>=3.0 # Note that original models trained with v3.4.0
smatch
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
'alignments/isi_hand_alignments/*.txt']},
packages=setuptools.find_packages(),
# Minimal requirements here. More extensive list in requirements.txt
install_requires=['penman>=1.1.0', 'torch>=1.6', 'numpy', 'spacy>=2.0,<3.0', 'tqdm', 'transformers>=3.0', 'smatch'],
install_requires=['penman>=1.1.0', 'torch>=1.6', 'numpy', 'spacy>=2.0', 'tqdm', 'transformers>=3.0', 'smatch'],
classifiers=[
'Programming Language :: Python :: 3',
'License :: OSI Approved :: MIT License',
Expand Down
2 changes: 1 addition & 1 deletion tests/auto/ModelGenericTypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
# The init time doesn't seem to get counted towards the total testing time.
# To avoid loading things multiple times, load in globally and reference it in __init__
# as needed.
SPACY_NLP = spacy.load('en')
SPACY_NLP = spacy.load('en_core_web_sm')
class ModelGenericTypes(unittest.TestCase):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
Expand Down

0 comments on commit 86736be

Please sign in to comment.