From 6a6bebb5fb3d8a7c55b6fdb280b39d80828d08f2 Mon Sep 17 00:00:00 2001 From: Ryan Amaral Date: Wed, 19 Jul 2017 16:24:02 -0300 Subject: [PATCH 1/3] removed encode call --- pycorenlp/corenlp.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycorenlp/corenlp.py b/pycorenlp/corenlp.py index 6eb2175..ccf4f0e 100644 --- a/pycorenlp/corenlp.py +++ b/pycorenlp/corenlp.py @@ -22,7 +22,7 @@ def annotate(self, text, properties=None): '$ cd stanford-corenlp-full-2015-12-09/ \n' '$ java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer') - data = text.encode() + data = text #.encode() r = requests.post( self.server_url, params={ 'properties': str(properties) From b699a5c966047007ce2f6461e09a608a3e6a0fd4 Mon Sep 17 00:00:00 2001 From: Ryan Amaral Date: Fri, 21 Jul 2017 14:55:21 -0300 Subject: [PATCH 2/3] update readme --- README.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/README.md b/README.md index 5b9bd48..2e77182 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,6 @@ +## My Contribution in this Fork +I removed a call to encode inside the annotate function so that text that is already encoded before being passed into the function will not crash it. + # py-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](http://stanfordnlp.github.io/CoreNLP/corenlp-server.html#api-documentation) for details. From 3399231d5a45a9feebcd415d6c0d2c6a95fafabc Mon Sep 17 00:00:00 2001 From: Ryan Amaral Date: Fri, 21 Jul 2017 14:59:40 -0300 Subject: [PATCH 3/3] put try catch around encode --- README.md | 3 --- pycorenlp/corenlp.py | 7 ++++++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 2e77182..5b9bd48 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,3 @@ -## My Contribution in this Fork -I removed a call to encode inside the annotate function so that text that is already encoded before being passed into the function will not crash it. - # py-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](http://stanfordnlp.github.io/CoreNLP/corenlp-server.html#api-documentation) for details. diff --git a/pycorenlp/corenlp.py b/pycorenlp/corenlp.py index ccf4f0e..061df81 100644 --- a/pycorenlp/corenlp.py +++ b/pycorenlp/corenlp.py @@ -21,8 +21,13 @@ def annotate(self, text, properties=None): raise Exception('Check whether you have started the CoreNLP server e.g.\n' '$ cd stanford-corenlp-full-2015-12-09/ \n' '$ java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer') + + # only encode if needed + try: + data = text.encode() + except: + data = text - data = text #.encode() r = requests.post( self.server_url, params={ 'properties': str(properties)