Java之词义相似度计算(语义识别词语情感趋势词林相似度拼音相似度概念相似度字面相似度)
Posted 蓝盒子itbluebox
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Java之词义相似度计算(语义识别词语情感趋势词林相似度拼音相似度概念相似度字面相似度)相关的知识,希望对你有一定的参考价值。
Java之词义相似度计算(语义识别、词语情感趋势、词林相似度、拼音相似度、概念相似度、字面相似度)
工具类下载地址:
https://download.csdn.net/download/qq_44757034/85765530
1、词语相似度计算
public class BaseDemo
public static void main(String[] args)
System.out.println("首次编译运行...");
double result = Similarity.cilinSimilarity("电动车","自行车");
System.out.println(result);
2、 短语相似度值
public class PhraseSimilarityDemo
public static void main(String[] args)
String phrase1 = "继续努力";
String phrase2 = "持续发展";
double result = Similarity.phraseSimilarity(phrase1, phrase2);
System.out.println(phrase1 + " vs " + phrase2 + " 短语相似度值:" + result);
3、 词形词序句子相似度值、优化的编辑距离句子相似度值、标准编辑距离句子相似度值、gregeor编辑距离句子相似度值
/**
* @author itbluebox
*/
public class SentenceSimilarityDemo
public static void main(String[] args)
String sentence1 = "老师办理教师资格证";
String sentence2 = "监理工程师资格证书";//"电脑病毒是有害的吗";
double morphoSimilarityResult = Similarity.morphoSimilarity(sentence1, sentence2);
double editDistanceResult = Similarity.editDistanceSimilarity(sentence1, sentence2);
double standEditDistanceResult = Similarity.standardEditDistanceSimilarity(sentence1,sentence2);
double gregeorEditDistanceResult = Similarity.gregorEditDistanceSimilarity(sentence1,sentence2);
System.out.println(sentence1 + " vs " + sentence2 + " 词形词序句子相似度值:" + morphoSimilarityResult);
System.out.println(sentence1 + " vs " + sentence2 + " 优化的编辑距离句子相似度值:" + editDistanceResult);
System.out.println(sentence1 + " vs " + sentence2 + " 标准编辑距离句子相似度值:" + standEditDistanceResult);
System.out.println(sentence1 + " vs " + sentence2 + " gregeor编辑距离句子相似度值:" + gregeorEditDistanceResult);
4、词语情感趋势值
/**
* @author itbluebox
*/
public class TendencyDemo
public static void main(String[] args)
String word = "混蛋";
HownetWordTendency hownetWordTendency = new HownetWordTendency();
double result = hownetWordTendency.getTendency(word);
System.out.println(word + " 词语情感趋势值:" + result);
5、词林相似度值、拼音相似度值、概念相似度值、字面相似度值
/**
* @author itbluebox
*/
public class WordSimilarityDemo
public static void main(String[] args)
String word1 = "老师办理教师资格证";
String word2 = "监理工程师资格证书";
double cilinSimilarityResult = Similarity.cilinSimilarity(word1, word2);
double pinyinSimilarityResult = Similarity.pinyinSimilarity(word1, word2);
double conceptSimilarityResult = Similarity.conceptSimilarity(word1, word2);
double charBasedSimilarityResult = Similarity.charBasedSimilarity(word1, word2);
System.out.println(word1 + " vs " + word2 + " 词林相似度值:" + cilinSimilarityResult);
System.out.println(word1 + " vs " + word2 + " 拼音相似度值:" + pinyinSimilarityResult);
System.out.println(word1 + " vs " + word2 + " 概念相似度值:" + conceptSimilarityResult);
System.out.println(word1 + " vs " + word2 + " 字面相似度值:" + charBasedSimilarityResult);
以上是关于Java之词义相似度计算(语义识别词语情感趋势词林相似度拼音相似度概念相似度字面相似度)的主要内容,如果未能解决你的问题,请参考以下文章