参考链接:
https://github.com/HIT-SCIR/ltp/blob/master/doc/install.rst
http://www.xfyun.cn/index.php/services/ltp/detail?&app_id=NTZmYzg5ZWE=
http://www.ltp-cloud.com/document/#api_rest_format_json
其他分词算法参考链接:
NLPIR:http://www.nlpir.org/ http://www.datatang.com/data/13483
bosonnlp: http://bosonnlp.com/
下面针对LTP分词算法 实践
1.登录官网 获取授权码api_key
2.分词接口操作
接口参数:
StringBuilder sb = new StringBuilder();
sb.Append(" 本报讯 (记者 王少勇)3月28日,国土资源部部长、党组书记、国家土地总督察姜大明主持召开第10次部党组会议,传达学习习xx总书记在北京市考察工作时的重要讲话精神。会议提出,要深刻理解习xx总书记重要讲话精神,充分发挥国土资源部门的服务和保障作用,推进京津冀协同发展。 xx平总书记高度重视北京发展和京津冀协同发展,今年2月下旬专程到北京市调研考察,并发表重要讲话,从做好北京发展和管理工作、推动京津冀协同发展两个方面进行了深刻阐述。会议指出,习xx总书记的重要讲话,对于实现京津冀优势互补、促进环渤海经济区发展、带动北方腹地发展,意义重大、影响深远,要认真学习,深刻领会。 会议提出,国土资源部门要进一步解放思想,加大改革创新力度,");
string url = "http://ltpapi.voicecloud.cn/analysis/";
string data = "api_key=xxx&text=" + sb.ToString() + "&pattern=ws&format=xml";
string returnValue= HttpHelper.HttpPost(url,data);
Console.WriteLine(returnValue);
Console.ReadKey();
/// <summary>
/// Post请求 webClient
/// </summary>
/// <param name="Url">地址</param>
/// <param name="postString">这里即为传递的参数,可以用工具抓包分析,也可以自己分析,主要是form里面每一个name都要加进来 </param>
/// <returns></returns>
public static string HttpPost(string url, string postString)
{
byte[] postData = Encoding.UTF8.GetBytes(postString);//编码,尤其是汉字,事先要看下抓取网页的编码方式
WebClient webClient = new WebClient();
webClient.Headers.Add("Content-Type", "application/x-www-form-urlencoded");//采取POST方式必须加的header,如果改为GET方式的话就去掉这句话即可
byte[] responseData = webClient.UploadData(url, "POST", postData);//得到返回字符流
string srcString = Encoding.UTF8.GetString(responseData);//解码
return srcString;
}
3.测试结果
<?xml version="1.0" encoding="utf-8" ?>
<xml4nlp>
<note sent="y" word="y" pos="n" ne="n" parser="n" wsd="n" srl="n" />
<doc>
<para id="">
<sent id="" cont="本报讯 (记者 王少勇)3月28日,国土资源部部长、党
组书记、国家土地总督察姜大明主持召开第10次部党组会议,传达学习习xx总书记在北京
市考察工作时的重要讲话精神。">
<word id="" cont="本报" />
<word id="" cont="讯" />
<word id="" cont="(" />
<word id="" cont="记者" />
<word id="" cont="王少勇" />
<word id="" cont=")" />
<word id="" cont="3月" />
<word id="" cont="28日" />
<word id="" cont="," />
<word id="" cont="国土" />
<word id="" cont="资源部" />
<word id="" cont="部长" />
<word id="" cont="、" />
<word id="" cont="党组" />
<word id="" cont="书记" />
<word id="" cont="、" />
<word id="" cont="国家" />
<word id="" cont="土地" />
<word id="" cont="总督" />
<word id="" cont="察姜" />
<word id="" cont="大明" />
<word id="" cont="主持" />
<word id="" cont="召开" />
<word id="" cont="第10" />
<word id="" cont="次" />
<word id="" cont="部党组" />
<word id="" cont="会议" />
<word id="" cont="," />
<word id="" cont="传达" />
<word id="" cont="学习" />
<word id="" cont="习" />
<word id="" cont="近平" />
<word id="" cont="总书记" />
<word id="" cont="在" />
<word id="" cont="北京市" />
<word id="" cont="考察" />
<word id="" cont="工作" />
<word id="" cont="时" />
<word id="" cont="的" />
<word id="" cont="重要" />
<word id="" cont="讲话" />
<word id="" cont="精神" />
<word id="" cont="。" />
</sent>
<sent id="" cont="会议提出,要深刻理解习xx总书记重要讲话精神,充
分发挥国土资源部门的服务和保障作用,推进京津冀协同发展。">
<word id="" cont="会议" />
<word id="" cont="提出" />
<word id="" cont="," />
<word id="" cont="要" />
<word id="" cont="深刻" />
<word id="" cont="理解" />
<word id="" cont="习" />
<word id="" cont="近平" />
<word id="" cont="总书记" />
<word id="" cont="重要" />
<word id="" cont="讲话" />
<word id="" cont="精神" />
<word id="" cont="," />
<word id="" cont="充分" />
<word id="" cont="发挥" />
<word id="" cont="国土" />
<word id="" cont="资源" />
<word id="" cont="部门" />
<word id="" cont="的" />
<word id="" cont="服务" />
<word id="" cont="和" />
<word id="" cont="保障" />
<word id="" cont="作用" />
<word id="" cont="," />
<word id="" cont="推进" />
<word id="" cont="京" />
<word id="" cont="津" />
<word id="" cont="冀" />
<word id="" cont="协同" />
<word id="" cont="发展" />
<word id="" cont="。" />
</sent>
<sent id="" cont="习xx总书记高度重视北京发展和京津冀协同发展,今
年2月下旬专程到北京市调研考察,并发表重要讲话,从做好北京发展和管理工作、推动京
津冀协同发展两个方面进行了深刻阐述。">
<word id="" cont="习" />
<word id="" cont="近平" />
<word id="" cont="总书记" />
<word id="" cont="高度" />
<word id="" cont="重视" />
<word id="" cont="北京" />
<word id="" cont="发展" />
<word id="" cont="和" />
<word id="" cont="京" />
<word id="" cont="津" />
<word id="" cont="冀" />
<word id="" cont="协同" />
<word id="" cont="发展" />
<word id="" cont="," />
<word id="" cont="今年" />
<word id="" cont="2月" />
<word id="" cont="下旬" />
<word id="" cont="专程" />
<word id="" cont="到" />
<word id="" cont="北京市" />
<word id="" cont="调研" />
<word id="" cont="考察" />
<word id="" cont="," />
<word id="" cont="并" />
<word id="" cont="发表" />
<word id="" cont="重要" />
<word id="" cont="讲话" />
<word id="" cont="," />
<word id="" cont="从" />
<word id="" cont="做好" />
<word id="" cont="北京" />
<word id="" cont="发展" />
<word id="" cont="和" />
<word id="" cont="管理" />
<word id="" cont="工作" />
<word id="" cont="、" />
<word id="" cont="推动" />
<word id="" cont="京" />
<word id="" cont="津" />
<word id="" cont="冀" />
<word id="" cont="协同" />
<word id="" cont="发展" />
<word id="" cont="两" />
<word id="" cont="个" />
<word id="" cont="方面" />
<word id="" cont="进行" />
<word id="" cont="了" />
<word id="" cont="深刻" />
<word id="" cont="阐述" />
<word id="" cont="。" />
</sent>
<sent id="" cont="会议指出,习xx总书记的重要讲话,对于实现京津冀
优势互补、促进环渤海经济区发展、带动北方腹地发展,意义重大、影响深远,要认真学习
,深刻领会。">
<word id="" cont="会议" />
<word id="" cont="指出" />
<word id="" cont="," />
<word id="" cont="习xx" />
<word id="" cont="总书记" />
<word id="" cont="的" />
<word id="" cont="重要" />
<word id="" cont="讲话" />
<word id="" cont="," />
<word id="" cont="对于" />
<word id="" cont="实现" />
<word id="" cont="京" />
<word id="" cont="津" />
<word id="" cont="冀" />
<word id="" cont="优势" />
<word id="" cont="互补" />
<word id="" cont="、" />
<word id="" cont="促进" />
<word id="" cont="环" />
<word id="" cont="渤海" />
<word id="" cont="经济区" />
<word id="" cont="发展" />
<word id="" cont="、" />
<word id="" cont="带动" />
<word id="" cont="北方" />
<word id="" cont="腹地" />
<word id="" cont="发展" />
<word id="" cont="," />
<word id="" cont="意义" />
<word id="" cont="重大" />
<word id="" cont="、" />
<word id="" cont="影响" />
<word id="" cont="深远" />
<word id="" cont="," />
<word id="" cont="要" />
<word id="" cont="认真" />
<word id="" cont="学习" />
<word id="" cont="," />
<word id="" cont="深刻" />
<word id="" cont="领会" />
<word id="" cont="。" />
</sent>
<sent id="" cont="会议提出,国土资源部门要进一步解放思想,加大改革
创新力度,">
<word id="" cont="会议" />
<word id="" cont="提出" />
<word id="" cont="," />
<word id="" cont="国土" />
<word id="" cont="资源" />
<word id="" cont="部门" />
<word id="" cont="要" />
<word id="" cont="进一步" />
<word id="" cont="解放思想" />
<word id="" cont="," />
<word id="" cont="加大" />
<word id="" cont="改革" />
<word id="" cont="创新" />
<word id="" cont="力度" />
<word id="" cont="," />
</sent>
</para>
</doc>
</xml4nlp>