|
Griffon 1.2.0 | |||||||
FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgriffon.util.CosineSimilarity
class CosineSimilarity
Uses cosine similarity to find matches from a candidate set for a specified input. Based on code from http://www.nearinfinity.com/blogs/seth_schroeder/groovy_cosine_similarity_in_grails.html
Constructor Summary | |
CosineSimilarity()
|
Method Summary | |
---|---|
private static Map
|
countNgramFrequency(def sequence, int degree)
|
private static double
|
dotProduct(Map m1, Map m2)
|
static List
|
mostSimilar(String pattern, def candidates, double threshold = 0)
Sort the candidates by their similarity to the specified input. |
private static double
|
similarity(def sequence1, def sequence2, int degree = 2)
|
private static double
|
stringSimilarity(String s1, String s2, int degree = 2)
|
Methods inherited from class Object | |
---|---|
wait, wait, wait, equals, toString, hashCode, getClass, notify, notifyAll |
Constructor Detail |
---|
CosineSimilarity()
Method Detail |
---|
private static Map countNgramFrequency(def sequence, int degree)
private static double dotProduct(Map m1, Map m2)
static List mostSimilar(String pattern, def candidates, double threshold = 0)
pattern
- the input stringcandidates
- the possible matches
private static double similarity(def sequence1, def sequence2, int degree = 2)
private static double stringSimilarity(String s1, String s2, int degree = 2)
Groovy Documentation