SeriousVenom

03.12.2020

Dec 3rd, 2020
558
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import requests
  2.  
  3.  
  4. class ParserUDP:
  5.     def __init__(self):
  6.         self.model = "russian-gsd-ud-2.6-200830"
  7.         self.url = "http://lindat.mff.cuni.cz/services/udpipe/api/process"
  8.  
  9.     def get_response(self, text):
  10.         my_dictionary = {
  11.             "data": text.encode("utf-8"),
  12.             "model": self.model,
  13.             "input": "horizontal",
  14.             "tokenizer": "T",
  15.             "tagger": "T",
  16.             "parser": "T"
  17.         }
  18.  
  19.     response = requests.get(self.url, params=my_dictionary)
  20.     if response.status_code == 200:
  21.         response = requests.get(self.url, params=my_dictionary).json()
  22.         for key in response:
  23.           print(response[key])
  24.     else:
  25.       print("Error")
  26.  
  27. def parse_responce:
  28.   '''
  29. Parse of the server and return list_words and return list_of_the_parents
  30. :return: two lists (words and their parents)
  31.  '''
  32.  
  33. def make_tree(self):
  34. '''
  35. Build tree as list_of_connectivity(dictionary)
  36. :return: dictionary of tree
  37. '''
  38.  
  39. def make_tree_depths(self):
  40.   '''
  41.  :return: number
  42.  '''
  43.  
  44. def to_graphviz(self):
  45.   '''
  46.  :return:
  47.  '''
  48.  
  49.  
  50. if __name__ == "__main__":
  51.   parseUPD = ParserUDP()
  52.   print(parseUPD.get_response("В лесу родилась ёлочка."))
  53.  
RAW Paste Data