Skip to content

Commit 8a6e332

Browse files
committed
simple readme
1 parent 11cadbf commit 8a6e332

File tree

4 files changed

+44
-20
lines changed

4 files changed

+44
-20
lines changed

neuralcoref/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1 @@
1-
import sys
21

3-
__project__ = "neuralcoref"
4-
__version__ = "0.1"
5-
__repo__ = "https://github.com/huggingface/neuralcoref"
6-
7-
from neuralcoref.algorithm import Algorithm
8-
9-
def print_version():
10-
sv = sys.version_info
11-
py_version = "{}.{}.{}".format(sv.major, sv.minor, sv.micro)
12-
version_parts = __version__.split(".")
13-
s = "{} version: [{}], Python {}".format(__project__, __version__, py_version)
14-
s += "\nMajor version: {} (breaking changes)".format(version_parts[0])
15-
s += "\nMinor version: {} (extra feature)".format(version_parts[1])
16-
s += "\nMicro version: {} (commit count)".format(version_parts[2])
17-
s += "\nFind out the most recent version at {}".format(__repo__)
18-
return s

neuralcoref/algorithm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def get_pair_mentions_score(self, antecedent, mention, pair_features):
6161
return self._score(first_layer_input, self.pair_mentions_model)
6262

6363

64-
class Algorithm:
64+
class Coref:
6565
'''
6666
Main coreference resolution algorithm
6767
'''

neuralcoref/server.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
from wsgiref.simple_server import make_server
1111
import falcon
1212

13-
from algorithm import Algorithm
13+
from algorithm import Coref
1414
from data import MENTION_LABEL
1515

1616
is_python2 = int(sys.version[0]) == 2
1717
unicode_ = unicode if is_python2 else str
1818

19-
class CorefWrapper(Algorithm):
19+
class CorefWrapper(Coref):
2020
def parse_and_get_mentions(self, utterances, utterances_speakers_id=None, context=None,
2121
context_speakers_id=None, speakers_names=None):
2222
self.data.set_utterances(context, context_speakers_id, speakers_names)

readme.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,42 @@
11
# Neural coref
2+
3+
A state-of-the-art coreference resolution system based on neural nets.
4+
5+
This coreference resolution system is based on the super fast (spaCy parser)[https://spacy.io/] and uses the high quality scoring neural network described in [Deep Reinforcement Learning for Mention-Ranking Coreference Models](http://cs.stanford.edu/people/kevclark/resources/clark-manning-emnlp2016-deep.pdf) by Kevin Clark and Christopher D. Manning, EMNLP 2016.
6+
7+
To know more about coreference adn neuralcoref, check out (our medium post)[https://medium.com/huggingface/state-of-the-art-neural-coreference-resolution-for-chatbots-3302365dcf30].
8+
9+
## Installation
10+
`pip install neuralcoref`
11+
12+
13+
You also need to download an english model for Spacy if you don't already have one.
14+
`python -m spacy download 'en'`
15+
16+
17+
The mention extraction algorithm depends quite strongly on the quality of the parsing so we would recommand to use a model with a good accuray.
18+
On the other hand, the coreference algorithm don't use spacy's model word vectors (although it could) so a good balance between parsing accuracy and model size is for example [spacy's 'en_depent_web_md' model](https://github.com/explosion/spacy-models/releases/en_depent_web_md-1.2.1) which has a parsing accuracy of 90.6% on Ontonotes 5.0.
19+
20+
You can get and use it like this
21+
````
22+
python -m spacy download 'en_depent_web_md'
23+
python -m spacy link en_depent_web_md en_default --force
24+
````
25+
26+
## Usage
27+
### Standalone server
28+
`python server.py` starts a wsgiref simple server on port 8000, endpoint `/coref/`.
29+
You can retreive coreferences on a text or dialogue utterances by calling the server.
30+
Example:
31+
`curl http://localhost:8001/coref?text=She%20loves%20him%20so%20much&context=My%20sister%20has%20a%20dog.`
32+
### Library
33+
````
34+
from neuralcoref import Coref
35+
coref = Coref()
36+
# retrieve all the coreference resolved clusters
37+
clusters = coref.one_shot_coref(u"My sister has a dog and she loves him.")
38+
print(clusters)
39+
# Show a dictionnary of resolved coreferences with the most representative mention of each cluster
40+
coreferences = coref.get_most_representative()
41+
pritn(coreferences)
42+
````

0 commit comments

Comments
 (0)