Total Complexity | 2 |
Total Lines | 9 |
Duplicated Lines | 0 % |
Changes | 6 | ||
Bugs | 0 | Features | 0 |
1 | import json |
||
5 | class StanfordNLP: |
||
6 | def __init__(self, port_number=9000): |
||
7 | self.server = "http://localhost:%d" % port_number |
||
8 | |||
9 | def parse(self, text): |
||
10 | r = requests.post(self.server, params={'properties' : '{"annotators": "tokenize,ssplit,pos,lemma,ner,parse", "outputFormat": "json", "parse.flags": " -makeCopulaHead"}'}, data=text.encode('utf8')) |
||
11 | result = r.json()['sentences'][0] |
||
12 | result['text'] = text |
||
13 | return result |
||
14 | |||
22 |