<jupyter_start><jupyter_text><jupyter_code>sudo apt-get install openjdk-8-jdk
sudo apt-get install maven

wget https://knowledgestore.fbk.eu/files/pikes/download/pikes-all.tar.gz # Download the full package
tar xzf pikes-all.tar.gz
cd pikes
bash run.sh
gcloud compute firewall-rules create pikes --allow tcp:8011 --source-tags=pikes --source-ranges=0.0.0.0/0 --description="pikes instance web server"
#!pip install stanfordnlp

import os
os.environ['PYTHONPATH'] = "/usr/local/bin/python"
!echo $PYTHONPATH
!which python
!python --version

import sys
sys.path.append('/usr/local/lib/python3.6/site-packages/')

import stanfordnlp
stanfordnlp.download('en', force=True)   

nlp = stanfordnlp.Pipeline() # This sets up a default neural pipeline in English
doc = nlp("<NAME> was born in Hawaii.  He was elected president in 2008.")
doc.sentences[0].print_dependencies()
from google.colab import drive
drive.mount('/content/gdrive')

#!cp /content/gdrive/My\ Drive/Colab\ Notebooks/Subtask-1/train_delex.jsonl /content
#!cp /content/gdrive/My\ Drive/Colab\ Notebooks/Subtask-1/test_delex.jsonl /content
import pandas as pd

prefix = '/content/'
#train_df = pd.read_json(prefix + 'test_delex.jsonl', orient='records', lines=True)
df = pd.read_json(prefix + 'test_delex.jsonl', orient='columns')
df.head()
# requests for fetching html of website
import requests

endpoint = 'http://172.16.31.10:8011/text2naf?text='

# Make the request to a url
r = requests.get(endpoint)
c = r.content
print(c)
#!pip install corenlp_xml
!pip install corenlp-xml
from corenlp_xml.document import Document

# requests for fetching html of website
import requests

endpoint = 'http://172.16.31.10:8011/text2naf?text='

for i in range(len(df)-6990) : 
  input_text = df.loc[i, "claim"]
  output_xml = requests.get(endpoint+input_text).content
  print(output_xml)

  d = Document(output_xml)
  print(d.sentences)

  for sentence in d.sentences:
    print(sentence)
    for token in sentence:
      print(token.word)
!pip install corenlpy
!pip install corenlp-xml-reader

from corenlpy import AnnotatedText as A

# requests for fetching html of website
import requests

endpoint = 'http://172.16.31.10:8011/text2naf?text='

for i in range(len(df)-6990) : 
  input_text = df.loc[i, "claim"]
  output_xml = requests.get(endpoint+input_text).content
  print(output_xml)

  xml = open(output_xml).read()
  annotated_text = A(xml)
  print(annotated_text)

  #Usually you’ll access parts of the document using the sentences list.
  len(annotated_text.sentences)
  sentence = annotated_text.sentences[0]
  print(sentence)
  print(sentence.keys())
  #['tokens', 'entities', 'references', 'mentions', 'root', 'id']

  #A Sentence is a special class that, for the most part, feels like a simple dict.
  #The tokens property is a list of the sentence’s tokens:

  tokens = sentence['tokens'][1]
  print(tokens)
  #' 0: Obama (10,14) NNP PERSON'

  term = sentence['tokens'][7]
  print(term)

  keys = tokens.keys()
  print(keys)
  #['word', 'character_offset_begin', 'character_offset_end', 'pos',<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12888601036269431, 'fraction_numerical': 0.02493523316062176, 'mean_word_length': 4.709796672828096, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 12}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 3, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '420779', 'license': 'Apache-2.0', 'n_tokens_mistral': 1138, 'n_tokens_neox': 1078, 'n_words': 276, 'path': 'Pikes.ipynb', 'repo_name': 'lenyabloko/SemEval2020', 'size': '3097'}