本文整理汇总了Java中com.hankcs.hanlp.dictionary.CoreSynonymDictionary类的典型用法代码示例。如果您正苦于以下问题:Java CoreSynonymDictionary类的具体用法?Java CoreSynonymDictionary怎么用?Java CoreSynonymDictionary使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CoreSynonymDictionary类属于com.hankcs.hanlp.dictionary包,在下文中一共展示了CoreSynonymDictionary类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: testWordUnion
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
private void testWordUnion(List<String> list) {
//List<String> list = new ArrayList<>();
List<String> keys = new ArrayList<>();
try {
RankRecordList result = new RankRecordList();
//file2Lines(getRawHome() + "/buty-keywords.txt", list);
file2Lines(getRawHome() + "/buty-keywords.txt", keys);
for (String s : list) {
double score = CoreSynonymDictionary.distance(s, "美丽") * 100000;
score += CoreSynonymDictionary.distance(s, "漂亮") * 100000;
score += CoreSynonymDictionary.distance(s, "可爱") * 100000;
for (String k : keys) {
score += CoreSynonymDictionary.distance(s, k);
}
result.add(s, score);
}
result.sortAsc();
result.listDetails();
lines2File(result.getWordList(), getRawHome() + "/buty-keywords2.txt");
} catch (IOException e) {
e.printStackTrace();
}
}
开发者ID:ltf,项目名称:lab,代码行数:25,代码来源:RankingTest.java
示例2: distanceClean
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
private void distanceClean() throws IOException {
Set<String> good = new HashSet<>();
Set<String> bad = new HashSet<>();
Set<String> buty = new HashSet<>();
file2Lines(getWordsHome() + "/badwords.txt", bad);
file2Lines(getWordsHome() + "/goodwords.txt", good);
file2Lines(getWordsHome() + "/buty.txt", buty);
RankRecordList recordList = new RankRecordList();
for (String s : good) {
double v = 0;
for (String s2 : buty) {
v += CoreSynonymDictionary.similarity(s, s2);
}
recordList.add(s, v / buty.size());
}
recordList.sortAsc();
recordList.listDetails();
lines2File(recordList.getWordList(), getWordsHome() + "/goodwords_.txt");
}
开发者ID:ltf,项目名称:lab,代码行数:22,代码来源:DataCleaner.java
示例3: main
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
public static void main(String[] args)
{
String[] wordArray = new String[]
{
"香蕉",
"苹果",
"白菜",
"水果",
"蔬菜",
"自行车",
"公交车",
"飞机",
"买",
"卖",
"购入",
"新年",
"春节",
"丢失",
"补办",
"办理",
"送给",
"寻找",
"孩子",
"教室",
"教师",
"会计",
};
System.out.printf("%-5s\t%-5s\t%-10s\t%-5s\n", "词A", "词B", "语义距离", "语义相似度");
for (String a : wordArray)
{
for (String b : wordArray)
{
System.out.printf("%-5s\t%-5s\t%-15d\t%-5.10f\n", a, b, CoreSynonymDictionary.distance(a, b), CoreSynonymDictionary.similarity(a, b));
}
}
}
开发者ID:priester,项目名称:hanlpStudy,代码行数:37,代码来源:DemoWordDistance.java
示例4: testDictionary
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
public void testDictionary() throws Exception
{
String apple = "苹果";
String banana = "香蕉";
String bike = "自行车";
CommonSynonymDictionary.SynonymItem synonymApple = CoreSynonymDictionary.get(apple);
CommonSynonymDictionary.SynonymItem synonymBanana = CoreSynonymDictionary.get(banana);
CommonSynonymDictionary.SynonymItem synonymBike = CoreSynonymDictionary.get(bike);
System.out.println(apple + " " + banana + "之间的距离是" + synonymApple.distance(synonymBanana));
System.out.println(apple + " " + bike + "之间的距离是" + synonymApple.distance(synonymBike));
}
开发者ID:priester,项目名称:hanlpStudy,代码行数:12,代码来源:TestSynonym.java
示例5: isSame
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
public static double isSame(String word, Set<String> targetSet) {
double v = 0;
for (String s : targetSet) {
v += CoreSynonymDictionary.similarity(word, s);
}
return v / targetSet.size();
}
开发者ID:ltf,项目名称:lab,代码行数:8,代码来源:Words.java
示例6: main
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
public static void main(String[] args)
{
String[] wordArray = new String[]{"栋","东","冬","雪"};
// {
// "香蕉",
// "苹果",
// "白菜",
// "水果",
// "蔬菜",
// "自行车",
// "公交车",
// "飞机",
// "买",
// "卖",
// "购入",
// "新年",
// "春节",
// "丢失",
// "补办",
// "办理",
// "送给",
// "寻找",
// "孩子",
// "教室",
// "教师",
// "会计",
// };
for (String a : wordArray)
{
for (String b : wordArray)
{
System.out.println(a + "\t" + b + "\t之间的距离是\t" + CoreSynonymDictionary.distance(a, b));
}
}
}
开发者ID:East196,项目名称:maker,代码行数:36,代码来源:DemoWordDistance.java
示例7: main
import com.hankcs.hanlp.dictionary.CoreSynonymDictionary; //导入依赖的package包/类
public static void main(String[] args)
{
String text = "这个方法可以利用同义词词典将一段文本改写成意思相似的另一段文本,而且差不多符合语法";
System.out.println(CoreSynonymDictionary.rewrite(text));
}
开发者ID:priester,项目名称:hanlpStudy,代码行数:6,代码来源:DemoRewriteText.java
注:本文中的com.hankcs.hanlp.dictionary.CoreSynonymDictionary类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论