Package: grails.util

## [Groovy] Class CosineSimilarity

- grails.util.CosineSimilarity

-     class CosineSimilarity
      extends java.lang.Object

  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

  Authors:
    Burt Beckwith

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CosineSimilarity ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `private static java.util.Map<java.util.List, java.lang.Integer>` | `countNgramFrequency(java.lang.Object sequence, int degree)`
    `` | `private static double` | `dotProduct(java.util.Map<java.util.List, java.lang.Integer> m1, java.util.Map<java.util.List, java.lang.Integer> m2)`
    `` | `static java.util.List<java.lang.String>` | `mostSimilar(java.lang.String pattern, java.lang.Object candidates, double threshold)` Sort the candidates by their similarity to the specified input.
    `` | `private static double` | `similarity(java.lang.Object sequence1, java.lang.Object sequence2, int degree)`
    `` | `private static double` | `stringSimilarity(java.lang.String s1, java.lang.String s2, int degree)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class java.lang.Object` | `java.lang.Object#wait(long), java.lang.Object#wait(long, int), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()`

- - ### Constructor Detail

    - #### CosineSimilarity()

  - ### Method Detail

    - #### private static java.util.Map<java.util.List, java.lang.Integer> countNgramFrequency(java.lang.Object sequence, int degree)

    - #### private static double dotProduct(java.util.Map<java.util.List, java.lang.Integer> m1, java.util.Map<java.util.List, java.lang.Integer> m2)

    - #### static java.util.List<java.lang.String> mostSimilar(java.lang.String pattern, java.lang.Object candidates, double threshold)

      Sort the candidates by their similarity to the specified input.

      Parameters:
        `pattern` - the input string
        `candidates` - the possible matches
      Returns:
        the ordered candidates

    - #### private static double similarity(java.lang.Object sequence1, java.lang.Object sequence2, int degree)

    - #### private static double stringSimilarity(java.lang.String s1, java.lang.String s2, int degree)