本文整理汇总了Java中org.simmetrics.metrics.StringMetrics类的典型用法代码示例。如果您正苦于以下问题:Java StringMetrics类的具体用法?Java StringMetrics怎么用?Java StringMetrics使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
StringMetrics类属于org.simmetrics.metrics包,在下文中一共展示了StringMetrics类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getSimilarity
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
public double getSimilarity(String sentence1, String sentence2){
double predictedScore = 0;
if (PARAGRAPHVECS != null) {
try {
INDArray inferredVectorA = produceParagraphVectorOfGivenSentence(sentence1);
INDArray inferredVectorB = produceParagraphVectorOfGivenSentence(sentence2);
predictedScore = Transforms.cosineSim(inferredVectorA, inferredVectorB);
} catch (Exception e) {
logger.error("No word is matched with the given sentence and any sentence in training set - model file. " + sentence1
+ ";" + sentence2);
System.out.println("No word is matched with the given sentence and any sentence in training set - model file. " + sentence1
+ ";" + sentence2);
StringMetric metric = StringMetrics.qGramsDistance();
predictedScore = metric.compare(sentence1, sentence2);
}
}
return predictedScore;
}
开发者ID:gizemsogancioglu,项目名称:biosses,代码行数:20,代码来源:SentenceVectorsBasedSimilarity.java
示例2: getSmsSimilarityScore
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
private static double getSmsSimilarityScore(String algo, String sms1, String sms2) {
Method method;
try {
method = StringMetrics.class.getMethod(algo);
StringMetric m = (StringMetric) method.invoke(null);
return m.compare(sms1, sms2);
} catch (IllegalAccessException | InvocationTargetException | SecurityException | NoSuchMethodException e) {
Log.e("GM/simError", e.toString());
return 0.0;
}
}
开发者ID:xRahul,项目名称:GroupingMessages,代码行数:12,代码来源:TrainSms.java
示例3: internalEvaluate
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
@Override
protected Value internalEvaluate(final Value... values) throws ExpressionEvaluationException {
final String firstString = assertStringLiteral(values[0]).stringValue();
final String secondString = assertStringLiteral(values[1]).stringValue();
return literal(StringMetrics.overlapCoefficient().compare(firstString, secondString));
}
开发者ID:semantalytics,项目名称:stardog-plugin-string-similarity,代码行数:9,代码来源:OverlapCoefficient.java
示例4: testDistances
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
@Ignore
@Test public void testDistances()
{
StringMetric similarity = StringMetrics.qGramsDistance();
System.out.println(similarity.compare("amountsextended","amountsextended"));
System.out.println(similarity.compare("amounts extended","extended amounts"));
System.out.println(similarity.compare("amountsextended","extendedamounts"));
System.out.println(similarity.compare("nestle","nestlé"));
System.out.println(similarity.compare("nerf","berg"));
}
开发者ID:AskNowQA,项目名称:cubeqa,代码行数:11,代码来源:ComponentPropertyTest.java
示例5: calculateSimilarityScoreForGivenPair
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
@WebMethod
public double calculateSimilarityScoreForGivenPair(String s1, String s2, int methodType) throws SLIB_Exception, IOException {
double similarityScore = 0;
System.out.println("REQUEST has been received for: " + s1 + " " + s2 + " " + methodType);
String preprocessedS1 = fileOperations.removeStopWordsFromSentence(s1, stopWordsList);
String preprocessedS2 = fileOperations.removeStopWordsFromSentence(s2, stopWordsList);
String example_1 = "It has recently been shown that Craf is essential for Kras G12D-induced NSCLC.";
String example_2 = "It has recently become evident that Craf is essential for the onset of Kras-driven non-small cell lung cancer.";
switch (methodType){
case 1:
//WordNet-based similarity was selected
CombinedOntologyMethod measureOfWordNet = new CombinedOntologyMethod(stopWordsList);
similarityScore = measureOfWordNet.getSimilarityForWordnet(s1, s2);
System.out.println("SCOREOFWORDNET: " + similarityScore);
break;
case 2:
//UMLS-based similarity option was selected
CombinedOntologyMethod measureOfUmls = new CombinedOntologyMethod(stopWordsList);
similarityScore = measureOfUmls.getSimilarityForUMLS(s1, s2);
System.out.println("SCOREOFUMLS: " + similarityScore);
break;
case 3:
//COMBINED ontology based similarity option was selected
CombinedOntologyMethod score_wordnet = new CombinedOntologyMethod(stopWordsList);
double score_1 =score_wordnet.getSimilarityForWordnet(s1, s2);
double score2 = score_wordnet.getSimilarityForUMLS(s1,s2);
similarityScore = (score2+score_1)/2;
System.out.println("SCOREOFCOMBINED: " + similarityScore);
break;
case 4:
//qgram string similarity option was selected.
StringMetric metric = StringMetrics.qGramsDistance();
similarityScore = metric.compare(preprocessedS1, preprocessedS2); //0.4767
System.out.println("SCOREOFQGRAM: "+similarityScore);
break;
case 5:
//paragraph vector model based similarity was selected as an option.
SentenceVectorsBasedSimilarity sentenceVectorsBasedSimilarity = new SentenceVectorsBasedSimilarity();
similarityScore = sentenceVectorsBasedSimilarity.getSimilarity(preprocessedS1, preprocessedS2);
System.out.println("SCOREOFPARAGRAPHVEC:" + similarityScore);
break;
case 6:
//Supervised Semantic Similarity was selected from the options list.
LinearRegressionMethod linearRegressionMethod = new LinearRegressionMethod();
similarityScore = linearRegressionMethod.getSimilarity(preprocessedS1, preprocessedS2);
System.out.println("SCOREOFSUPERVISED: " + similarityScore);
break;
}
return similarityScore;
}
开发者ID:gizemsogancioglu,项目名称:biosses,代码行数:58,代码来源:SSESService.java
示例6: getSimilarity
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
public double getSimilarity(String sentence1, String sentence2) throws IOException {
StringMetric metric = StringMetrics.needlemanWunch();
float result = metric.compare(sentence1, sentence2); //0.4767
return result;
}
开发者ID:gizemsogancioglu,项目名称:biosses,代码行数:7,代码来源:SimMetricFunctions.java
示例7: Lookup
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
protected Lookup() {
super();
metric = StringMetrics.levenshtein();
}
开发者ID:ML-Schema,项目名称:openml-rdf,代码行数:5,代码来源:Lookup.java
示例8: jaccardSimilarity
import org.simmetrics.metrics.StringMetrics; //导入依赖的package包/类
public static float jaccardSimilarity(String sentence1, String sentence2){
StringMetric metric = StringMetrics.jaccard();
float result = metric.compare(sentence1, sentence2); //0.4767
return result;
}
开发者ID:gizemsogancioglu,项目名称:biosses,代码行数:8,代码来源:SimMetricFunctions.java
注:本文中的org.simmetrics.metrics.StringMetrics类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论