为什么不使用Stanford CoreNLP服务器!
1.)启动服务器!
java -Xmx4g edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 - timeout 15000
import requestsurl = "http://localhost:9000/tregex"request_params = {"pattern": "(NP[$VP]>S)|(NP[$VP]>S\n)|(NP\n[$VP]>S)|(NP\n[$VP]>S\n)"}text = "Pusheen and Smitha walked along the beach."r = requests.post(url, data=text, params=request_params)print r.json()
3.)结果如下!
{u'sentences': [{u'0': {u'namedNodes': [], u'match': u'(NP (NNP Pusheen)n (CC and)n (NNP Smitha))n'}}]}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)