From f39282abe9747df61f099ca398228d4cf50aef0b Mon Sep 17 00:00:00 2001 From: Michele Filannino Date: Fri, 7 Nov 2014 08:57:35 +0000 Subject: [PATCH 1/2] Added --corenlp parameter It gives the possibility of initialising the StanfordCoreNLP server by specifying a custom corenlp source folder. --- client.py | 4 +++- corenlp.py | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/client.py b/client.py index 11097ce..230fe27 100644 --- a/client.py +++ b/client.py @@ -11,7 +11,9 @@ def parse(self, text): return json.loads(self.server.parse(text)) nlp = StanfordNLP() -result = nlp.parse("Hello world! It is so beautiful.") +text = '\n\n A New York man who was accused of faking his death last summer pleaded guilty to a conspiracy charge Thursday, Nassau County District Attorney Kathleen Rice announced.\n\nRaymond Roth, 48, of Massapequa, New York, was first reported missing in the waters off Jones Beach late last July by his 22-year-old son, Jonathan Roth. Several days into an extensive search involving multiple agencies, New York State Park Police said, authorities learned the missing man was in South Carolina, where he had been pulled over for speeding.\n\nThe day before Raymond Roth was pulled over, his wife, Evana, showed authorities e-mails she had discovered that appeared to detail a plan between him and his son to fake his death. Raymond Roth wanted his wife and son to collect at least $410,000 in life insurance benefits while he started a new life in Florida, Rice said.\n\nState police arrested both men in early August on charges of insurance fraud, conspiracy and filing a false report. Raymond Roth on Thursday agreed to plead guilty to the conspiracy charge in exchange for a sentence of 90 days in jail and five years\' probation, the district attorney\'s office said. He also must pay restitution for the cost of the search -- $27,445 to the U.S. Coast Guard and $9,109 to the Nassau County Police Department.' +print "Text length: {}".format(len(text)) +result = nlp.parse(text) pprint(result) from nltk.tree import Tree diff --git a/corenlp.py b/corenlp.py index 753e51c..550359e 100644 --- a/corenlp.py +++ b/corenlp.py @@ -250,11 +250,13 @@ def parse(self, text): help='Port to serve on (default: 8080)') parser.add_option('-H', '--host', default='127.0.0.1', help='Host to serve on (default: 127.0.0.1. Use 0.0.0.0 to make public)') + parser.add_option('-S', '--corenlp', default=None, + help='Stanford CoreNLP tool directory') options, args = parser.parse_args() server = jsonrpc.Server(jsonrpc.JsonRpc20(), jsonrpc.TransportTcpIp(addr=(options.host, int(options.port)))) - nlp = StanfordCoreNLP() + nlp = StanfordCoreNLP(corenlp_path=options.corenlp) server.register_function(nlp.parse) logger.info('Serving on http://%s:%s' % (options.host, options.port)) From 86d8b130d99f50811a566bf16255d04694b4d185 Mon Sep 17 00:00:00 2001 From: Michele Filannino Date: Fri, 7 Nov 2014 09:00:17 +0000 Subject: [PATCH 2/2] Hello World text back. --- client.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/client.py b/client.py index 230fe27..11097ce 100644 --- a/client.py +++ b/client.py @@ -11,9 +11,7 @@ def parse(self, text): return json.loads(self.server.parse(text)) nlp = StanfordNLP() -text = '\n\n A New York man who was accused of faking his death last summer pleaded guilty to a conspiracy charge Thursday, Nassau County District Attorney Kathleen Rice announced.\n\nRaymond Roth, 48, of Massapequa, New York, was first reported missing in the waters off Jones Beach late last July by his 22-year-old son, Jonathan Roth. Several days into an extensive search involving multiple agencies, New York State Park Police said, authorities learned the missing man was in South Carolina, where he had been pulled over for speeding.\n\nThe day before Raymond Roth was pulled over, his wife, Evana, showed authorities e-mails she had discovered that appeared to detail a plan between him and his son to fake his death. Raymond Roth wanted his wife and son to collect at least $410,000 in life insurance benefits while he started a new life in Florida, Rice said.\n\nState police arrested both men in early August on charges of insurance fraud, conspiracy and filing a false report. Raymond Roth on Thursday agreed to plead guilty to the conspiracy charge in exchange for a sentence of 90 days in jail and five years\' probation, the district attorney\'s office said. He also must pay restitution for the cost of the search -- $27,445 to the U.S. Coast Guard and $9,109 to the Nassau County Police Department.' -print "Text length: {}".format(len(text)) -result = nlp.parse(text) +result = nlp.parse("Hello world! It is so beautiful.") pprint(result) from nltk.tree import Tree