Created
January 9, 2019 08:15
-
-
Save Elfsong/58d1be8095ee2a5e1afff1de6e1e1d52 to your computer and use it in GitHub Desktop.
LTP online demo fetch
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
############################# | |
Wanxiang Che, Zhenghua Li, Ting Liu. | |
LTP: A Chinese Language Technology Platform. | |
In Proceedings of the Coling 2010:Demonstrations. 2010.08, pp13-16, Beijing, China. | |
############################# | |
import requests | |
def fetch(sentence): | |
url = "http://api.ltp.yunfutech.com/ltp/OutLTP" | |
payload = "{\"sent\":\"%s\",\"last\":{\"sent\":true,\"word\":true,\"pos\":true,\"ne\":true,\"parser\":true," \ | |
"\"srl\":true,\"semparser\":true,\"semgraphparser\":true}}" % sentence | |
payload = payload.encode("utf-8") | |
headers = { | |
'Accept': "*/*", | |
'Referer': "http://ltp.ai/demo.html", | |
'Origin': "http://ltp.ai", | |
'User-Agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) " | |
"Chrome/71.0.3578.98 Safari/537.36", | |
'Content-Type': "application/json", | |
'cache-control': "no-cache", | |
} | |
response = requests.request("POST", url, data=payload, headers=headers) | |
return response.json() | |
if __name__ == "__main__": | |
result = fetch("他叫汤姆去拿外衣") | |
print(result) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment