Skip to content

Instantly share code, notes, and snippets.

@henryyang42
Created July 4, 2017 22:25
Show Gist options
  • Save henryyang42/ff3073eb4e8aada222e34ce84169cf1b to your computer and use it in GitHub Desktop.
Save henryyang42/ff3073eb4e8aada222e34ce84169cf1b to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import requests"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"{\"xmlstr\":\"<?xml version=\\\"1.0\\\" encoding=\\\"GBK\\\"?>\\n\\n<FSP4XML>\\n <para id=\\\"0\\\">\\n <word word_id=\\\"0\\\" lexicalunit=\\\"邓伟\\\" pos=\\\"nh\\\" role=\\\"S-spkr\\\" ner=\\\"S-Nh\\\" head=\\\"2\\\" deprels=\\\"SBV\\\"/>\\n <word word_id=\\\"1\\\" lexicalunit=\\\"介绍\\\" pos=\\\"v\\\" role=\\\"tgt\\\" ner=\\\"O\\\" head=\\\"0\\\" deprels=\\\"HED\\\"/>\\n <word word_id=\\\"2\\\" lexicalunit=\\\"该书\\\" pos=\\\"r\\\" role=\\\"B-msg\\\" ner=\\\"O\\\" head=\\\"2\\\" deprels=\\\"VOB\\\"/>\\n <word word_id=\\\"3\\\" lexicalunit=\\\"共计\\\" pos=\\\"v\\\" role=\\\"I-msg\\\" ner=\\\"O\\\" head=\\\"2\\\" deprels=\\\"COO\\\"/>\\n <word word_id=\\\"4\\\" lexicalunit=\\\"80\\\" pos=\\\"m\\\" role=\\\"I-msg\\\" ner=\\\"O\\\" head=\\\"7\\\" deprels=\\\"ATT\\\"/>\\n <word word_id=\\\"5\\\" lexicalunit=\\\"余\\\" pos=\\\"m\\\" role=\\\"I-msg\\\" ner=\\\"O\\\" head=\\\"5\\\" deprels=\\\"RAD\\\"/>\\n <word word_id=\\\"6\\\" lexicalunit=\\\"万\\\" pos=\\\"m\\\" role=\\\"I-msg\\\" ner=\\\"O\\\" head=\\\"8\\\" deprels=\\\"ATT\\\"/>\\n <word word_id=\\\"7\\\" lexicalunit=\\\"字\\\" pos=\\\"n\\\" role=\\\"E-msg\\\" ner=\\\"O\\\" head=\\\"4\\\" deprels=\\\"VOB\\\"/>\\n <word word_id=\\\"8\\\" lexicalunit=\\\"。\\\" pos=\\\"wp\\\" role=\\\"O\\\" ner=\\\"O\\\" head=\\\"2\\\" deprels=\\\"WP\\\"/>\\n <\\/para>\\n <para id=\\\"1\\\">\\n <word word_id=\\\"0\\\" lexicalunit=\\\"邓伟\\\" pos=\\\"nh\\\" role=\\\"O\\\" ner=\\\"S-Nh\\\" head=\\\"2\\\" deprels=\\\"SBV\\\"/>\\n <word word_id=\\\"1\\\" lexicalunit=\\\"介绍\\\" pos=\\\"v\\\" role=\\\"O\\\" ner=\\\"O\\\" head=\\\"0\\\" deprels=\\\"HED\\\"/>\\n <word word_id=\\\"2\\\" lexicalunit=\\\"该书\\\" pos=\\\"r\\\" role=\\\"S-attr\\\" ner=\\\"O\\\" head=\\\"2\\\" deprels=\\\"VOB\\\"/>\\n <word word_id=\\\"3\\\" lexicalunit=\\\"共计\\\" pos=\\\"v\\\" role=\\\"tgt\\\" ner=\\\"O\\\" head=\\\"2\\\" deprels=\\\"COO\\\"/>\\n <word word_id=\\\"4\\\" lexicalunit=\\\"80\\\" pos=\\\"m\\\" role=\\\"B-val\\\" ner=\\\"O\\\" head=\\\"7\\\" deprels=\\\"ATT\\\"/>\\n <word word_id=\\\"5\\\" lexicalunit=\\\"余\\\" pos=\\\"m\\\" role=\\\"I-val\\\" ner=\\\"O\\\" head=\\\"5\\\" deprels=\\\"RAD\\\"/>\\n <word word_id=\\\"6\\\" lexicalunit=\\\"万\\\" pos=\\\"m\\\" role=\\\"I-val\\\" ner=\\\"O\\\" head=\\\"8\\\" deprels=\\\"ATT\\\"/>\\n <word word_id=\\\"7\\\" lexicalunit=\\\"字\\\" pos=\\\"n\\\" role=\\\"E-val\\\" ner=\\\"O\\\" head=\\\"4\\\" deprels=\\\"VOB\\\"/>\\n <word word_id=\\\"8\\\" lexicalunit=\\\"。\\\" pos=\\\"wp\\\" role=\\\"O\\\" ner=\\\"O\\\" head=\\\"2\\\" deprels=\\\"WP\\\"/>\\n <\\/para>\\n<\\/FSP4XML>\\n\",\"jsonstr\":\"[\\n [\\n {\\n \\\"word_id\\\": \\\"0\\\",\\n \\\"role\\\": \\\"S-spkr\\\",\\n \\\"ner\\\": \\\"S-Nh\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"SBV\\\",\\n \\\"lexicaluni\\\": \\\"邓伟\\\",\\n \\\"pos\\\": \\\"nh\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"1\\\",\\n \\\"role\\\": \\\"tgt\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"0\\\",\\n \\\"deprels\\\": \\\"HED\\\",\\n \\\"lexicaluni\\\": \\\"介绍\\\",\\n \\\"pos\\\": \\\"v\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"2\\\",\\n \\\"role\\\": \\\"B-msg\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"VOB\\\",\\n \\\"lexicaluni\\\": \\\"该书\\\",\\n \\\"pos\\\": \\\"r\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"3\\\",\\n \\\"role\\\": \\\"I-msg\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"COO\\\",\\n \\\"lexicaluni\\\": \\\"共计\\\",\\n \\\"pos\\\": \\\"v\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"4\\\",\\n \\\"role\\\": \\\"I-msg\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"7\\\",\\n \\\"deprels\\\": \\\"ATT\\\",\\n \\\"lexicaluni\\\": \\\"80\\\",\\n \\\"pos\\\": \\\"m\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"5\\\",\\n \\\"role\\\": \\\"I-msg\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"5\\\",\\n \\\"deprels\\\": \\\"RAD\\\",\\n \\\"lexicaluni\\\": \\\"余\\\",\\n \\\"pos\\\": \\\"m\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"6\\\",\\n \\\"role\\\": \\\"I-msg\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"8\\\",\\n \\\"deprels\\\": \\\"ATT\\\",\\n \\\"lexicaluni\\\": \\\"万\\\",\\n \\\"pos\\\": \\\"m\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"7\\\",\\n \\\"role\\\": \\\"E-msg\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"4\\\",\\n \\\"deprels\\\": \\\"VOB\\\",\\n \\\"lexicaluni\\\": \\\"字\\\",\\n \\\"pos\\\": \\\"n\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"8\\\",\\n \\\"role\\\": \\\"O\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"WP\\\",\\n \\\"lexicaluni\\\": \\\"。\\\",\\n \\\"pos\\\": \\\"wp\\\"\\n }\\n ],\\n [\\n {\\n \\\"word_id\\\": \\\"0\\\",\\n \\\"role\\\": \\\"O\\\",\\n \\\"ner\\\": \\\"S-Nh\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"SBV\\\",\\n \\\"lexicaluni\\\": \\\"邓伟\\\",\\n \\\"pos\\\": \\\"nh\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"1\\\",\\n \\\"role\\\": \\\"O\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"0\\\",\\n \\\"deprels\\\": \\\"HED\\\",\\n \\\"lexicaluni\\\": \\\"介绍\\\",\\n \\\"pos\\\": \\\"v\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"2\\\",\\n \\\"role\\\": \\\"S-attr\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"VOB\\\",\\n \\\"lexicaluni\\\": \\\"该书\\\",\\n \\\"pos\\\": \\\"r\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"3\\\",\\n \\\"role\\\": \\\"tgt\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"COO\\\",\\n \\\"lexicaluni\\\": \\\"共计\\\",\\n \\\"pos\\\": \\\"v\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"4\\\",\\n \\\"role\\\": \\\"B-val\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"7\\\",\\n \\\"deprels\\\": \\\"ATT\\\",\\n \\\"lexicaluni\\\": \\\"80\\\",\\n \\\"pos\\\": \\\"m\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"5\\\",\\n \\\"role\\\": \\\"I-val\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"5\\\",\\n \\\"deprels\\\": \\\"RAD\\\",\\n \\\"lexicaluni\\\": \\\"余\\\",\\n \\\"pos\\\": \\\"m\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"6\\\",\\n \\\"role\\\": \\\"I-val\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"8\\\",\\n \\\"deprels\\\": \\\"ATT\\\",\\n \\\"lexicaluni\\\": \\\"万\\\",\\n \\\"pos\\\": \\\"m\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"7\\\",\\n \\\"role\\\": \\\"E-val\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"4\\\",\\n \\\"deprels\\\": \\\"VOB\\\",\\n \\\"lexicaluni\\\": \\\"字\\\",\\n \\\"pos\\\": \\\"n\\\"\\n },\\n {\\n \\\"word_id\\\": \\\"8\\\",\\n \\\"role\\\": \\\"O\\\",\\n \\\"ner\\\": \\\"O\\\",\\n \\\"head\\\": \\\"2\\\",\\n \\\"deprels\\\": \\\"WP\\\",\\n \\\"lexicaluni\\\": \\\"。\\\",\\n \\\"pos\\\": \\\"wp\\\"\\n }\\n ]\\n]\",\"jsons\":[{\"result\":[{\"id\":\"0\",\"lex\":\"邓伟\",\"ner\":\"S-Nh\",\"mark\":\"S-spkr\",\"head\":\"2\",\"deprels\":\"SBV\",\"pos\":\"nh\"},{\"id\":\"1\",\"lex\":\"介绍\",\"ner\":\"O\",\"mark\":\"tgt\",\"head\":\"0\",\"deprels\":\"HED\",\"pos\":\"v\"},{\"id\":\"2\",\"lex\":\"该书\",\"ner\":\"O\",\"mark\":\"B-msg\",\"head\":\"2\",\"deprels\":\"VOB\",\"pos\":\"r\"},{\"id\":\"3\",\"lex\":\"共计\",\"ner\":\"O\",\"mark\":\"I-msg\",\"head\":\"2\",\"deprels\":\"COO\",\"pos\":\"v\"},{\"id\":\"4\",\"lex\":\"80\",\"ner\":\"O\",\"mark\":\"I-msg\",\"head\":\"7\",\"deprels\":\"ATT\",\"pos\":\"m\"},{\"id\":\"5\",\"lex\":\"余\",\"ner\":\"O\",\"mark\":\"I-msg\",\"head\":\"5\",\"deprels\":\"RAD\",\"pos\":\"m\"},{\"id\":\"6\",\"lex\":\"万\",\"ner\":\"O\",\"mark\":\"I-msg\",\"head\":\"8\",\"deprels\":\"ATT\",\"pos\":\"m\"},{\"id\":\"7\",\"lex\":\"字\",\"ner\":\"O\",\"mark\":\"E-msg\",\"head\":\"4\",\"deprels\":\"VOB\",\"pos\":\"n\"},{\"id\":\"8\",\"lex\":\"。\",\"ner\":\"O\",\"mark\":\"O\",\"head\":\"2\",\"deprels\":\"WP\",\"pos\":\"wp\"}],\"tgtindex\":1,\"frame\":\"陈述\",\"ismarked\":true,\"score\":0.95482,\"tgt\":\"介绍 v\"},{\"result\":[{\"id\":\"0\",\"lex\":\"邓伟\",\"ner\":\"S-Nh\",\"mark\":\"O\",\"head\":\"2\",\"deprels\":\"SBV\",\"pos\":\"nh\"},{\"id\":\"1\",\"lex\":\"介绍\",\"ner\":\"O\",\"mark\":\"O\",\"head\":\"0\",\"deprels\":\"HED\",\"pos\":\"v\"},{\"id\":\"2\",\"lex\":\"该书\",\"ner\":\"O\",\"mark\":\"S-attr\",\"head\":\"2\",\"deprels\":\"VOB\",\"pos\":\"r\"},{\"id\":\"3\",\"lex\":\"共计\",\"ner\":\"O\",\"mark\":\"tgt\",\"head\":\"2\",\"deprels\":\"COO\",\"pos\":\"v\"},{\"id\":\"4\",\"lex\":\"80\",\"ner\":\"O\",\"mark\":\"B-val\",\"head\":\"7\",\"deprels\":\"ATT\",\"pos\":\"m\"},{\"id\":\"5\",\"lex\":\"余\",\"ner\":\"O\",\"mark\":\"I-val\",\"head\":\"5\",\"deprels\":\"RAD\",\"pos\":\"m\"},{\"id\":\"6\",\"lex\":\"万\",\"ner\":\"O\",\"mark\":\"I-val\",\"head\":\"8\",\"deprels\":\"ATT\",\"pos\":\"m\"},{\"id\":\"7\",\"lex\":\"字\",\"ner\":\"O\",\"mark\":\"E-val\",\"head\":\"4\",\"deprels\":\"VOB\",\"pos\":\"n\"},{\"id\":\"8\",\"lex\":\"。\",\"ner\":\"O\",\"mark\":\"O\",\"head\":\"2\",\"deprels\":\"WP\",\"pos\":\"wp\"}],\"tgtindex\":3,\"frame\":\"共计\",\"ismarked\":true,\"score\":0.403029,\"tgt\":\"共计 v\"}],\"xmlname\":\"1499207047448-xml.xml\",\"senjsons\":[{\"lem\":\"邓伟\"},{\"lem\":\"介绍\",\"istgt\":true},{\"lem\":\"该书\"},{\"lem\":\"共计\",\"istgt\":true},{\"lem\":\"80\"},{\"lem\":\"余\"},{\"lem\":\"万\"},{\"lem\":\"字\"},{\"lem\":\"。\"}],\"jsonstr-src\":[[{\"word_id\":\"0\",\"role\":\"S-spkr\",\"ner\":\"S-Nh\",\"head\":\"2\",\"deprels\":\"SBV\",\"lexicaluni\":\"邓伟\",\"pos\":\"nh\"},{\"word_id\":\"1\",\"role\":\"tgt\",\"ner\":\"O\",\"head\":\"0\",\"deprels\":\"HED\",\"lexicaluni\":\"介绍\",\"pos\":\"v\"},{\"word_id\":\"2\",\"role\":\"B-msg\",\"ner\":\"O\",\"head\":\"2\",\"deprels\":\"VOB\",\"lexicaluni\":\"该书\",\"pos\":\"r\"},{\"word_id\":\"3\",\"role\":\"I-msg\",\"ner\":\"O\",\"head\":\"2\",\"deprels\":\"COO\",\"lexicaluni\":\"共计\",\"pos\":\"v\"},{\"word_id\":\"4\",\"role\":\"I-msg\",\"ner\":\"O\",\"head\":\"7\",\"deprels\":\"ATT\",\"lexicaluni\":\"80\",\"pos\":\"m\"},{\"word_id\":\"5\",\"role\":\"I-msg\",\"ner\":\"O\",\"head\":\"5\",\"deprels\":\"RAD\",\"lexicaluni\":\"余\",\"pos\":\"m\"},{\"word_id\":\"6\",\"role\":\"I-msg\",\"ner\":\"O\",\"head\":\"8\",\"deprels\":\"ATT\",\"lexicaluni\":\"万\",\"pos\":\"m\"},{\"word_id\":\"7\",\"role\":\"E-msg\",\"ner\":\"O\",\"head\":\"4\",\"deprels\":\"VOB\",\"lexicaluni\":\"字\",\"pos\":\"n\"},{\"word_id\":\"8\",\"role\":\"O\",\"ner\":\"O\",\"head\":\"2\",\"deprels\":\"WP\",\"lexicaluni\":\"。\",\"pos\":\"wp\"}],[{\"word_id\":\"0\",\"role\":\"O\",\"ner\":\"S-Nh\",\"head\":\"2\",\"deprels\":\"SBV\",\"lexicaluni\":\"邓伟\",\"pos\":\"nh\"},{\"word_id\":\"1\",\"role\":\"O\",\"ner\":\"O\",\"head\":\"0\",\"deprels\":\"HED\",\"lexicaluni\":\"介绍\",\"pos\":\"v\"},{\"word_id\":\"2\",\"role\":\"S-attr\",\"ner\":\"O\",\"head\":\"2\",\"deprels\":\"VOB\",\"lexicaluni\":\"该书\",\"pos\":\"r\"},{\"word_id\":\"3\",\"role\":\"tgt\",\"ner\":\"O\",\"head\":\"2\",\"deprels\":\"COO\",\"lexicaluni\":\"共计\",\"pos\":\"v\"},{\"word_id\":\"4\",\"role\":\"B-val\",\"ner\":\"O\",\"head\":\"7\",\"deprels\":\"ATT\",\"lexicaluni\":\"80\",\"pos\":\"m\"},{\"word_id\":\"5\",\"role\":\"I-val\",\"ner\":\"O\",\"head\":\"5\",\"deprels\":\"RAD\",\"lexicaluni\":\"余\",\"pos\":\"m\"},{\"word_id\":\"6\",\"role\":\"I-val\",\"ner\":\"O\",\"head\":\"8\",\"deprels\":\"ATT\",\"lexicaluni\":\"万\",\"pos\":\"m\"},{\"word_id\":\"7\",\"role\":\"E-val\",\"ner\":\"O\",\"head\":\"4\",\"deprels\":\"VOB\",\"lexicaluni\":\"字\",\"pos\":\"n\"},{\"word_id\":\"8\",\"role\":\"O\",\"ner\":\"O\",\"head\":\"2\",\"deprels\":\"WP\",\"lexicaluni\":\"。\",\"pos\":\"wp\"}]]}\n"
]
}
],
"source": [
"url = 'http://115.24.12.89:8080/autoanno/servlet/GetAutomaticResult'\n",
"sentence = '邓伟介绍该书共计80余万字。'\n",
"headers = {'Content-Type' : 'application/x-www-form-urlencoded; charset=UTF-8'}\n",
"res = requests.post(url, data={'sentence': sentence}, headers=headers)\n",
"\n",
"print(res.text)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment