public class SimilarityUtils extends Object
Some convenient string utilities.
Modifier and Type | Field and Description |
---|---|
protected static Pattern |
NGRAM_PATTERN |
Constructor and Description |
---|
SimilarityUtils() |
Modifier and Type | Method and Description |
---|---|
protected static Map<String,Integer> |
computeNGrams(int startOrder,
int maxOrder,
String text)
Compute N Grams.
|
protected static Map<String,Integer> |
computeWord2count(String text)
Calculate word frequency.
|
protected static double |
similarity(Map<String,Integer> ngramsA,
Map<String,Integer> ngramsB)
Calculate similarity between two sets of n grams
|
static double |
similarity(String textA,
String textB)
Calculate similarity between two text based on trigram.
|
static double |
wordSim(String textA,
String textB)
Calculate string similarity based on ugram of words.
|
protected static final Pattern NGRAM_PATTERN
protected static Map<String,Integer> computeNGrams(int startOrder, int maxOrder, String text)
startOrder
- maxOrder
- text
- protected static Map<String,Integer> computeWord2count(String text)
Calculate word frequency.
text
- a text to processprotected static double similarity(Map<String,Integer> ngramsA, Map<String,Integer> ngramsB)
Calculate similarity between two sets of n grams
ngramsA
- a set of n gramsngramsB
- a set of n gramspublic static double similarity(String textA, String textB)
Calculate similarity between two text based on trigram.
textA
- text AtextB
- text BCopyright © 2011-2016 Ubiquitous Knowledge Processing (UKP) Lab. All Rights Reserved.