Last active
December 3, 2016 09:02
-
-
Save j-min/23946eb9706d3fd30fde06685344c437 to your computer and use it in GitHub Desktop.
Get tokenized list from dparser
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import requests | |
def tokenize_dparser(text): | |
dparser_link = 'http://parser.datanada.com/parse?version=1&string=' | |
url = dparser_link+text | |
response = requests.get(url) | |
data = json.loads(response.content.decode('utf-8')) # list of dictionaries | |
""" | |
ex) 안녕하세요 | |
[{'deprel': 'ROOT', 'form': '안녕', 'pos': 'NNG', 'id': '1', 'head': '0'}, | |
{'deprel': 'VP', 'form': '하', 'pos': 'XSV', 'id': '2', 'head': '1'}, | |
{'deprel': 'VP', 'form': '세요', 'pos': 'EP+EF', 'id': '3', 'head': '2'}] | |
""" | |
return [x['form'] for x in data] | |
if __name__ = '__main__': | |
input_string = input() | |
tokenizer_dparser(input_string) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment