Stanford CoreNLP

1. direct call

CoreNLP

a jar package wrapper in python

2. Server

CoreNLP Server

Run Server

# Set up your classpath. For example, to add all jars in the current directory tree:
export CLASSPATH="`find . -name '*.jar'`"

# Run the server
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer [port=9000]

# send post data & get parameter to the server
wget --post-data 'the quick brown fox jumped over the lazy dog' 'localhost:9000/?properties={"tokenize.whitespace": "true", "annotators": "tokenize,ssplit,pos", "outputFormat": "json"}' -O -

# Run with Chinese
java -cp "*" -Xmx8g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -serverProperties StanfordCoreNLP-chinese.properties -port 19000

# request
wget --post-data '我爱北京天安门' 'localhost:19000/?properties={"outputFormat":"json"}' -O -

Kill Server

C-c

or

wget "localhost:9000/shutdown?key=`cat /tmp/corenlp.shutdown`" -O -

python talking with server install lib:

pip install pycorenlp

how to use:

from pycorenlp import StanfordCoreNLP

if __name__ == '__main__':
    nlp = StanfordCoreNLP('http://localhost:9000')
    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'])
    output = nlp.tokensregex(text, pattern='/Pusheen|Smitha/', filter=False)
    print(output)
    output = nlp.semgrex(text, pattern='{tag: VBD}', filter=False)
    print(output)

3. demo

http://corenlp.run/

NLTK (python)

http://www.nltk.org/

source: https://github.com/nltk/nltk

spaCy.io (python)

https://spacy.io/