Example #1
0
        public static double CosineSimilarity2(this string source, string target)
        {
            TokeniserUtilities <string> _tokenUtilities = new TokeniserUtilities <string>();

            if (source != null && target != null && _tokenUtilities.CreateMergedSet(_tokeniser.Tokenize(source), _tokeniser.Tokenize(target)).Count > 0)
            {
                return(_tokenUtilities.CommonSetTerms() / (Math.Pow(_tokenUtilities.FirstSetTokenCount, 0.5) * Math.Pow(_tokenUtilities.SecondSetTokenCount, 0.5)));
            }
            return(0.0);
        }
Example #2
0
        public static double OverlapCoefficientSimilarity(this string firstWord, string secondWord)
        {
            TokeniserUtilities <string> _tokenUtilities = new TokeniserUtilities <string>();

            if (firstWord != null && secondWord != null)
            {
                _tokenUtilities.CreateMergedSet(_tokeniser.Tokenize(firstWord), _tokeniser.Tokenize(secondWord));
                return(_tokenUtilities.CommonSetTerms() / (double)Math.Min(_tokenUtilities.FirstSetTokenCount, _tokenUtilities.SecondSetTokenCount));
            }
            return(DefaultMismatchScore);
        }