old_contents: # Temporary inclusion of pycorenlp code for easier edits
  # https://github.com/smilli/py-corenlp
  
  import json, requests
  
  class StanfordCoreNLP:
  
      def __init__(self, server_url):
          if server_url[-1] == '/':
              server_url = server_url[:-1]
          self.server_url = server_url
  
      def annotate(self, text, properties=None):
          assert isinstance(text, str) or isinstance(text,unicode)
          if properties is None:
              properties = {}
          else:
              assert isinstance(properties, dict)
  
          # Checks that the Stanford CoreNLP server is started.
          try:
              requests.get(self.server_url)
          except requests.exceptions.ConnectionError:
              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')
  
          data = text.encode('utf8')
          r = requests.post(
              self.server_url, params={
                  'properties': str(properties)
              }, data=data, headers={'Connection': 'close'})
          output = r.text
          if ('outputFormat' in properties
               and properties['outputFormat'] == 'json'):
              try:
                  output = json.loads(output, encoding='utf-8', strict=False)
              except:
                  print("TEXT")
                  print(unicode(text))
                  print("OUTPUT")
                  print(unicode(output))
                  raise RuntimeError("CoreNLP returned data not in JSON format")
  
          return output
  
      def tokensregex(self, text, pattern, filter):
          return self.regex('/tokensregex', text, pattern, filter)
  
      def semgrex(self, text, pattern, filter):
          return self.regex('/semgrex', text, pattern, filter)
  
      def regex(self, endpoint, text, pattern, filter):
          r = requests.get(
              self.server_url + endpoint, params={
                  'pattern':  pattern,
                  'filter': filter
              }, data=text)
          output = r.text
          try:
              output = json.loads(r.text)
          except:
              pass
          return output
  
new_contents: # Temporary inclusion of pycorenlp code for easier edits
  # https://github.com/smilli/py-corenlp
  
  import json, requests
  
  class StanfordCoreNLP:
  
      def __init__(self, server_url):
          if server_url[-1] == '/':
              server_url = server_url[:-1]
          self.server_url = server_url
  
      def annotate(self, text, properties={}):
          assert isinstance(text, str) or isinstance(text,unicode)
          assert isinstance(properties, dict)
  
          # Checks that the Stanford CoreNLP server is started.
          try:
              requests.get(self.server_url)
          except requests.exceptions.ConnectionError:
              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')
  
          data = text.encode('utf8')
          r = requests.post(
              self.server_url, params={
                  'properties': str(properties)
              }, data=data, headers={'Connection': 'close'})
          output = r.text
          if ('outputFormat' in properties
               and properties['outputFormat'] == 'json'):
              try:
                  output = json.loads(output, encoding='utf-8', strict=False)
              except:
                  raise RuntimeError("CoreNLP returned data not in JSON format")
  
          return output
  
  
subject: Remove unused code from my pycorenlp