public double Compare(WordData word1, WordData word2) { double answer = 0; if (word1.GetWord().Length == word2.GetWord().Length) { double tolerance = 200; int length = word1.GetWord().Length - 1; int count = 0; for (int i = 0; i < length; i++) { double numerator = tolerance; if (i < length && i < word2.GetWord().Length - 1) { numerator -= Math.Abs(word1.GetTiming()[i] - word2.GetTiming()[i]); answer += numerator / tolerance; count++; } } answer = answer / (count); if (answer < 0) { answer = 0; } bool stop; if (answer > 1) { stop = true; } } return(answer); }
public double MeanCompare(WordData word, List <WordData> wordList) { double answer = 0; int[] timing = new int[word.GetTiming().Length]; for (int i = 0; i < word.GetTiming().Length; ++i) { int mean = 0; foreach (WordData listWord in wordList) { mean += listWord.GetTiming()[i]; } mean /= wordList.Count; timing[i] = mean; } WordData meanWord = new WordData(word.GetWord(), timing, -1); answer = Compare(word, meanWord); return(answer); }
public double MedianCompare(WordData word, List <WordData> wordList) { double answer = 0; int[] timing = new int[word.GetTiming().Length]; for (int i = 0; i < word.GetTiming().Length; ++i) { List <int> medianList = new List <int>(); int median = 0; foreach (WordData listWord in wordList) { medianList.Add(listWord.GetTiming()[i]); } medianList.Sort(); median = medianList[(wordList.Count / 2)]; timing[i] = median; } WordData meanWord = new WordData(word.GetWord(), timing, -1); answer = Compare(word, meanWord); return(answer); }