Skip to content

Commit 86736be

Browse files
committed
minor updates for spacy 3.x
1 parent 5194ef6 commit 86736be

File tree

5 files changed

+9
-10
lines changed

5 files changed

+9
-10
lines changed

amrlib/graph_processing/annotator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,11 @@ def _process_penman(pen, tokens=None):
6969
pen.metadata['ner_iob'] = json.dumps([t.ent_iob_ for t in tokens])
7070
pen.metadata['pos_tags'] = json.dumps([t.tag_ for t in tokens])
7171
# Create lemmas
72-
# SpaCy's lemmatizer returns -PRON- for pronouns so strip these
72+
# The spaCy 2.0 lemmatizer returns -PRON- for pronouns so strip these (spaCy 3.x does not do this)
7373
# Don't try to lemmatize any named-entities or proper nouns. Lower-case any other words.
7474
lemmas = []
7575
for t in tokens:
76-
if t.lemma_ == '-PRON-':
76+
if t.lemma_ == '-PRON-': # spaCy 2.x only
7777
lemma = t.text.lower()
7878
elif t.tag_.startswith('NNP') or t.ent_type_ not in ('', 'O'):
7979
lemma = t.text

req_tested_versions.txt

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@
22
PyQt5 version: 5.15.0
33
graphviz version: 0.14.1
44
nltk version: 3.5
5-
numpy version: 1.19.1
5+
numpy version: 1.20.1
66
penman version: 1.1.0
77
requests version: 2.22.0
88
smatch version: 1.0.4
9-
spacy version: 2.3.2
10-
torch version: 1.7.0
9+
spacy version: 3.0.5
10+
torch version: 1.8.0
1111
tqdm version: 4.48.2
12-
transformers version: 4.0.0
12+
transformers version: 4.2.2
1313
unidecode version: 1.1.1
1414
word2number version: 1.1
15-

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
penman>=1.1.0
44
torch>=1.6
55
numpy
6-
spacy>=2.0,<3.0 # also requires model download `python -m spacy download en_core_web_sm`
6+
spacy>=2.0 # also requires model download `python -m spacy download en_core_web_sm`
77
tqdm
88
transformers>=3.0 # Note that original models trained with v3.4.0
99
smatch

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
'alignments/isi_hand_alignments/*.txt']},
3939
packages=setuptools.find_packages(),
4040
# Minimal requirements here. More extensive list in requirements.txt
41-
install_requires=['penman>=1.1.0', 'torch>=1.6', 'numpy', 'spacy>=2.0,<3.0', 'tqdm', 'transformers>=3.0', 'smatch'],
41+
install_requires=['penman>=1.1.0', 'torch>=1.6', 'numpy', 'spacy>=2.0', 'tqdm', 'transformers>=3.0', 'smatch'],
4242
classifiers=[
4343
'Programming Language :: Python :: 3',
4444
'License :: OSI Approved :: MIT License',

tests/auto/ModelGenericTypes.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# The init time doesn't seem to get counted towards the total testing time.
2929
# To avoid loading things multiple times, load in globally and reference it in __init__
3030
# as needed.
31-
SPACY_NLP = spacy.load('en')
31+
SPACY_NLP = spacy.load('en_core_web_sm')
3232
class ModelGenericTypes(unittest.TestCase):
3333
def __init__(self, *args, **kwargs):
3434
super().__init__(*args, **kwargs)

0 commit comments

Comments
 (0)