package com.test;
import org.junit.Test;
import com.boso.Bosonnlp;
import com.enumBean.TypeBean;
import com.mashape.unirest.http.exceptions.UnirestException;
import com.util.Util;
public class BosoNnlpTest {
@Test
public void sentiment() throws UnirestException {
String [] data = new String[]{"中国共产党", "美好的世界"};
System.out.println(Bosonnlp.determine(TypeBean.SENTIMENT.getDesc(),data));
//第一个值为非负面概率,第二个值为负面概率,两个值相加和为 1
//[[0.6519134382562579,0.34808656174374203],[0.92706110187413,0.07293889812586994]]
}
/**
* 命名实体识别(NER)是指识别文本中具有特定意义的实体,主要包括人名、地名、机构名、
* 专有名词等。命名实体识别是信息提取、问答系统、句法分析、机器翻译等应用领域的重要基础工具
* @author wangbo
*/
@Test
public void ner() throws UnirestException {
String [] data = new String[]{"对于该小孩是不是郑尚金的孩子,目前已做亲子鉴定,结果还没出来,纪检部门仍在调查之中。成都商报记者 姚永忠"};
System.out.println(Bosonnlp.ner(data));
}
/**
* 依存文法分析核心思想为将一个线性描写的句子表述为成员之间的搭配与驱动关系
* @author wangbo
*/
@Test
public void depparser() throws UnirestException {
String [] data = new String[]{"我以最快的速度吃了午饭"};
System.out.println(Bosonnlp.determine(TypeBean.DEPPARSER.getDesc(),data));
//[{"head":[6,6,3,4,5,1,-1,6,6],
//"role":["SBJ","MNR","VMOD","DEC","NMOD","POBJ","ROOT","VMOD","OBJ"],
//"tag":["PN","P","AD","VA","DEC","NN","VV","AS","NN"],"word":["我","以","最","快","的","速度","吃","了","午饭"]}]
}
/**
* 以将文本自动进行关键词分析,给出每个词语相应的权重
* @author wangbo
*/
@Test
public void keywords() throws UnirestException {
String [] data = new String[]{"病毒式媒体网站:让新闻迅速蔓延"};
System.out.println(Bosonnlp.determine(TypeBean.KEYWORDS.getDesc(),data));
//[[[0.5686631749811326,"蔓延"],
//[0.5671956747680966,"病毒"],
//[0.33993439662135194,"迅速"],
//[0.30642011458238383,"网站"],
//[0.26392731183346607,"新闻"],[0.23807884315568398,"媒体"],[0.12876489756725826,"式"],[0.0504282185215189,"让"]]]
}
/**
* 将新闻文本归类到预设的 14 个分类当中
0体育1教育2财经3社会4娱乐5军事6国内7 科技8 互联网9房产10国际11女人12 汽车13游戏
* @author wangbo
*/
@Test
public void classify() throws UnirestException {
String [] data = new String[]{ "俄否决安理会谴责叙军战机空袭阿勒颇平民",
"邓紫棋谈男友林宥嘉:我觉得我比他唱得好",
"Facebook收购印度初创公司"};
String str = Bosonnlp.determine(TypeBean.CLASSIFY.getDesc(),data);
String classify[] = str.substring(str.indexOf("[")+1, str.indexOf("]")).split(",");
for (String string : classify) {
System.out.println(Util.classify(Integer.parseInt(string)));
}
//[5,4,8]
}
@Test
public void suggest() throws UnirestException {
String data = "\"傻逼\"";
System.out.println(Bosonnlp.suggest(TypeBean.SUGGEST.getDesc(),data));
}
/**
* 将中文时间描述转换为三种标准的时间格式的时间字符串:1) 时间点(timestamp,表示某一具体时间时间描述); 2) 时间量(timedelta,表示时间的增量的时间描述); 3)时间区间(timespan,大于一天的有具体起始和结束时间点的时间描述),以方便处理。在转换时以尽量保留原始时间描述中所含信息为原则。
* @author wangbo
*/
@Test
public void time() throws UnirestException {
String [] data = new String[]{};
System.out.println(Bosonnlp.time(TypeBean.TIME.getDesc(),data,"2013年二月二十八日下午四点三十分二十九秒"));
//{"type":"timestamp","timestamp":"2013-02-28 16:30:29"}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
BosoNnlp.rar (45个子文件)
BosoNnlp
bin
junit-4.12.jar 308KB
httpcore-nio-4.4.10.jar 357KB
ezmorph-1.0.6.jar 84KB
jackson-databind-2.9.5.jar 1.28MB
unirest-java-1.4.5.jar 42KB
com
test
BosoNnlpTest.class 3KB
enumBean
TypeBean.class 2KB
util
Util.class 3KB
boso
Bosonnlp.class 3KB
commons-logging-1.1.1.jar 59KB
commons-beanutils-1.8.0.jar 226KB
httpclient-4.3.6.jar 578KB
commons-collections-3.2.2.jar 575KB
httpasyncclient-4.0-beta4.jar 151KB
httpcore-4.4.6.jar 316KB
commons-lang-2.5.jar 273KB
json-lib-2.4-jdk15.jar 155KB
hamcrest-core-1.3.rc2.jar 40KB
json-20171018.jar 60KB
jackson-annotations-2.9.0.jar 65KB
jackson-core-2.9.5.jar 314KB
.settings
org.eclipse.jdt.core.prefs 598B
src
com
test
BosoNnlpTest.java 3KB
enumBean
TypeBean.java 976B
util
Util.java 2KB
boso
Bosonnlp.java 3KB
.project 384B
.classpath 2KB
lib
junit-4.12.jar 308KB
httpcore-nio-4.4.10.jar 357KB
ezmorph-1.0.6.jar 84KB
jackson-databind-2.9.5.jar 1.28MB
unirest-java-1.4.5.jar 42KB
commons-logging-1.1.1.jar 59KB
commons-beanutils-1.8.0.jar 226KB
httpclient-4.3.6.jar 578KB
commons-collections-3.2.2.jar 575KB
httpasyncclient-4.0-beta4.jar 151KB
httpcore-4.4.6.jar 316KB
commons-lang-2.5.jar 273KB
json-lib-2.4-jdk15.jar 155KB
hamcrest-core-1.3.rc2.jar 40KB
json-20171018.jar 60KB
jackson-annotations-2.9.0.jar 65KB
jackson-core-2.9.5.jar 314KB
共 45 条
- 1
资源评论
大数据左右手
- 粉丝: 432
- 资源: 2
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功