diff --git a/pycorenlp/corenlp.py b/pycorenlp/corenlp.py index 6eb2175..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)