smilli/py-corenlp
smilli/py-corenlp has 356 GitHub stars and 72 forks. GitHot measured +1 stars in 24 hours. Last checked 2026-11-17 03:33 UTC. Last push 2020-12-02.
Measured star growth
- in 24h
- +1
- in 7 days
- Update delayed
- in 15 days
- Update delayed
- in 1 month
- Update delayed
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
About
Python wrapper for Stanford CoreNLP
Developer ToolsREADME.md
Originalpy-corenlp
Python wrapper for Stanford CoreNLP. This simply wraps the API from the server included with CoreNLP 3.6.0. See the CoreNLP server API documentation for details.
Install
pip install pycorenlp
Usage
First make sure you have the Stanford CoreNLP server running. See the instructions here for how to do that.
Then the setup just requires you to pass in the url of the server:
>>> from pycorenlp import StanfordCoreNLP
>>> nlp = StanfordCoreNLP('http://localhost:9000')
Supports annotation:
>>> text = (
'Pusheen and Smitha walked along the beach. '
'Pusheen wanted to surf, but fell off the surfboard.')
>>> output = nlp.annotate(text, properties={
'annotators': 'tokenize,ssplit,pos,depparse,parse',
'outputFormat': 'json'
})
>>> print(output['sentences'][0]['parse'])
(ROOT
(S
(NP (NNP Pusheen)
(CC and)
(NNP Smitha))
(VP (VBD walked)
(PP (IN along)
(NP (DT the) (NN beach))))
(. .)))
And tokensregex + semgrex
>>> nlp.tokensregex(text, pattern='/Pusheen|Smitha/', filter=False)
{u'sentences': [
{
u'1': {u'text': u'Smitha', u'begin': 2, u'end': 3},
u'0': {u'text': u'Pusheen', u'begin': 0, u'end': 1}, u'length': 2
},
{u'0': {u'text': u'Pusheen', u'begin': 0, u'end': 1}, u'length': 1}]}
>>> nlp.semgrex(text, pattern='{tag: VBD}', filter=False)
{u'sentences': [
{u'0': {u'text': u'walked', u'begin': 3, u'end': 4}, u'length': 1},
{
u'1': {u'text': u'fell', u'begin': 6, u'end': 7},
u'0': {u'text': u'wanted', u'begin': 1, u'end': 2}, u'length': 2
}
]}
The code above is available in example.py.