Skip to content

Commit 3c8650d

Browse files
authored
Merge pull request #15 from thomwolf/master
Update to spaCy 2
2 parents 22ef144 + e28ed5f commit 3c8650d

File tree

4 files changed

+15
-27
lines changed

4 files changed

+15
-27
lines changed

neuralcoref/data.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -527,16 +527,7 @@ def add_utterances(self, utterances, utterances_speaker=None, speakers_names=Non
527527
utterances_speaker = ((i + a + 1) % 2 for i in range(len(utterances)))
528528
utterances_index = []
529529
utt_start = len(self.utterances)
530-
for utt_index, (utterance, speaker_id) in enumerate(zip_longest(utterances, utterances_speaker)):
531-
if utterance is None:
532-
break
533-
# Pipe currently broken in spacy 2 alpha
534-
# Also, spacy 2 currently throws an exception on empty strings
535-
try:
536-
doc = self.nlp(utterance)
537-
except IndexError:
538-
doc = self.nlp(u" ")
539-
if self.debug: print("Empty string")
530+
for utt_index, (doc, speaker_id) in enumerate(zip_longest(self.nlp.pipe(utterances), utterances_speaker)):
540531
if speaker_id not in self.speakers:
541532
speaker_name = speakers_names.get(speaker_id, None) if speakers_names else None
542533
self.speakers[speaker_id] = Speaker(speaker_id, speaker_name)

readme.md

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,21 @@ This coreference resolution module is based on the super fast [spaCy](https://sp
88
Be sure to check out [our medium post](https://medium.com/huggingface/state-of-the-art-neural-coreference-resolution-for-chatbots-3302365dcf30) in which we talk more about neuralcoref and coreference resolution.
99

1010
## Installation
11-
Clone the repo (the trained model weights are too large for PyPI)
11+
Clone the repo and install using pip (the trained model weights are too large for PyPI)
1212

1313
```
14+
git clone git@github.com:huggingface/neuralcoref.git
1415
cd neuralcoref
15-
pip install -r requirements.txt
16+
pip install .
1617
```
1718

1819

19-
You will also need an English model for spaCy if you don't already have spaCy installed.
20+
You will also need an English model for spaCy if you don't already have spaCy installed in your environment.
2021
````
2122
python -m spacy download 'en'
2223
````
2324

24-
The mention extraction module is strongly influenced by the quality of the parsing so we recommend selecting a model with a higher accuray than usual. Since the coreference algorithm don't make use of spaCy's word vectors, a medium sized spaCy model like ['en_depent_web_md'](https://github.com/explosion/spacy-models/releases/en_depent_web_md-1.2.1) can strike a good balance between memory footprint and parsing accuracy.
25-
26-
To download and install the ['en_depent_web_md'](https://github.com/explosion/spacy-models/releases/en_depent_web_md-1.2.1) model:
27-
````
28-
python -m spacy download 'en_depent_web_md'
29-
python -m spacy link en_depent_web_md en
30-
````
31-
32-
If you are an early user of [spacy 2 alpha](https://github.com/explosion/spaCy/releases/tag/v2.0.0-alpha), you can use `neuralcoref` with spacy 2 without any specific modification.
25+
The mention extraction module is strongly influenced by the quality of the parsing so we recommend selecting a model with a higher accuray than usual.
3326

3427
## Usage
3528
### As a standalone server

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ python-mimeparse==1.6.0
1616
regex==2017.4.5
1717
requests==2.18.1
1818
six==1.10.0
19-
spacy==2.0.4
19+
spacy==2.0.7
2020
termcolor==1.1.0
2121
thinc==6.5.2
2222
toolz==0.8.2

setup.py

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,14 @@
1717
'Programming Language :: Python :: 3.4',
1818
'Programming Language :: Python :: 3.5'
1919
],
20-
packages=find_packages(),
21-
include_package_data=True,
22-
package_data={'neuralcoref': ['neuralcoref/weights/*.npy']},
23-
20+
install_requires=[
21+
'numpy',
22+
'spacy',
23+
'falcon'],
24+
packages=['neuralcoref'],
25+
package_dir={'neuralcoref': 'neuralcoref'},
26+
package_data={'neuralcoref': ['weights/*.npy',
27+
'weights/*.txt']},
2428
keywords='NLP chatbots coreference resolution',
2529
license='MIT',
2630
zip_safe=False,

0 commit comments

Comments
 (0)