// ---------------------------------------------------------------------------------------- /// <!-- CompareAll --> /// <summary> /// Compares two corpuses returning scores for all words in either corpus /// </summary> /// <param name="myBible"></param> /// <param name="resumes"></param> /// <returns></returns> public static Dictionary <string, double> CompareAll(Corpus myBible, Corpus resumes) { double bibleCount = myBible.TotalWords(); double resumeCount = resumes.TotalWords(); double ratio = bibleCount / resumeCount; Dictionary <string, double> either = new Dictionary <string, double>(); foreach (string word in myBible.RegularWord.Keys) { either.Add(word, myBible.RegularWord[word] * 2.0); } foreach (string word in resumes.RegularWord.Keys) { if (either.ContainsKey(word)) { double newValue = myBible.RegularWord[word] / resumes.RegularWord[word]; either[word] = newValue; } else { either.Add(word, 0.5 / resumes.RegularWord[word]); } } return(either); }
// ---------------------------------------------------------------------------------------- /// <!-- Compare --> /// <summary> /// Compares two corpuses /// </summary> /// <param name="corpusA"></param> /// <param name="corpusB"></param> /// <returns></returns> public static string Compare(Corpus corpusA, Corpus corpusB) { Dictionary <string, double> both = Corpus.CompareCommon(corpusA, corpusB); Dictionary <string, double> thisOne = Corpus.CompareAll(corpusA, corpusB); List <string> corpusB_Both = Corpus.OrderWordsLowToHigh(both); List <string> corpusB_This = Corpus.OrderWordsLowToHigh(thisOne); List <string> corpusA_Both = Corpus.OrderWordsHighToLow(both); List <string> corpusA_This = Corpus.OrderWordsHighToLow(thisOne); int colWidth = 24; string str = (corpusB.TotalWords().ToString() + " words").PadRight(colWidth * 2) + (corpusA.TotalWords().ToString() + " words").PadRight(colWidth * 2); str += "\r\n"; str += (corpusB.DisplayName + "(both)").PadRight(colWidth) + (corpusB.DisplayName + "(this)").PadRight(colWidth) + (corpusA.DisplayName + "(both)").PadRight(colWidth) + (corpusA.DisplayName + "(this)").PadRight(colWidth) ; str += "\r\n"; str += "----------".PadRight(colWidth); str += "----------".PadRight(colWidth); str += "----------".PadRight(colWidth); str += "----------".PadRight(colWidth); for (int i = 0; i < 50; ++i) { str += "\r\n" + corpusB_Both[i].PadRight(colWidth) + corpusB_This[i].PadRight(colWidth) + corpusA_Both[i].PadRight(colWidth) + corpusA_This[i].PadRight(colWidth); } return(str); }