NamedEntityExtractorSK.Finder.CompareStrings C# (CSharp) Method

CompareStrings() public method

Compares the two strings based on letter pair matches
public CompareStrings ( string str1, string str2 ) : double
str1 string
str2 string
return double
		public double CompareStrings(string str1, string str2)
		{
			List<string> pairs1 = WordLetterPairs(str1.ToUpper());
			List<string> pairs2 = WordLetterPairs(str2.ToUpper());

			int intersection = 0;
			int union = pairs1.Count + pairs2.Count;

			for (int i = 0; i < pairs1.Count; i++)
			{
				for (int j = 0; j < pairs2.Count; j++)
				{
					if (pairs1[i] == pairs2[j])
					{
						intersection++;
						pairs2.RemoveAt(j);//Must remove the match to prevent "GGGG" from appearing to match "GG" with 100% success

						break;
					}
				}
			}

			return (2.0 * intersection) / union;
		}