-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsyntax_rest.py
More file actions
28 lines (23 loc) · 922 Bytes
/
syntax_rest.py
File metadata and controls
28 lines (23 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#-*-coding: utf-8 -*-
import requests
import json, os
url = "{0}:{1}".format("localhost" , "9000")
# [Required]
# make new docker for rest-service and add model "syntaxnet"
# add option to docker run "--link syntaxnet:syntaxnet-rest-api"
# Reference : https://github.com/ljm625/syntaxnet-rest-api
# Call Syntaxnet
resp = requests.post('http://' + url + '/api/v1/query',
json={
"strings": ["핵실험 준비가 완료된 상태로 보인다고 밝혔다"]
}
)
"""
return value is (On AWS console tested not use docker)
[{'pos_tag': 'JJ', 'dep': 'ROOT', 'contains':
[{'pos_tag': 'NNP', 'dep': 'nsubj', 'name': 'Google'},
{'pos_tag': 'VBZ', 'dep': 'cop', 'name': 'is'},
{'pos_tag': '.', 'dep': 'punct', 'name': '!'}],
'name': 'awesome'}]
"""
print(json.dumps(resp.json(),ensure_ascii=False))