Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- class ParserUDP:
- def __init__(self):
- self.model = "russian-gsd-ud-2.6-200830"
- self.url = "http://lindat.mff.cuni.cz/services/udpipe/api/process"
- def get_response(self, text):
- my_dictionary = {
- "data": text.encode("utf-8"),
- "model": self.model,
- "input": "horizontal",
- "tokenizer": "T",
- "tagger": "T",
- "parser": "T"
- }
- response = requests.get(self.url, params=my_dictionary)
- if response.status_code == 200:
- response = requests.get(self.url, params=my_dictionary).json()
- for key in response:
- print(response[key])
- else:
- print("Error")
- def parse_responce:
- '''
- Parse of the server and return list_words and return list_of_the_parents
- :return: two lists (words and their parents)
- '''
- def make_tree(self):
- '''
- Build tree as list_of_connectivity(dictionary)
- :return: dictionary of tree
- '''
- def make_tree_depths(self):
- '''
- :return: number
- '''
- def to_graphviz(self):
- '''
- :return:
- '''
- if __name__ == "__main__":
- parseUPD = ParserUDP()
- print(parseUPD.get_response("В лесу родилась ёлочка."))
Advertisement
Add Comment
Please, Sign In to add comment