public void CalculatePriority_CharacterSubstitutionFrequencyIntermediate() { testCandidateWordPriorityCalculator = new CandidateWordPriorityCalculator(20, 0, 0, 0, 1, allWordsTrieRoot, fromCharacterFrequencies, characterSubstitutionFrequencies); Double result = testCandidateWordPriorityCalculator.CalculatePriority("read", "real", "mate", 20); Assert.AreEqual(0.5, result); }
public void CalculatePriority_CharacterSubstitutionFrequencyMinimum() { testCandidateWordPriorityCalculator = new CandidateWordPriorityCalculator(20, 0, 0, 0, 1, allWordsTrieRoot, fromCharacterFrequencies, characterSubstitutionFrequencies); Double result = testCandidateWordPriorityCalculator.CalculatePriority("mall", "malt", "mate", 20); Assert.AreEqual(1.0, result); }
public void CalculatePriority_CandidateToDestinationMatchingCharactersDifferingCounts() { testCandidateWordPriorityCalculator = new CandidateWordPriorityCalculator(20, 0, 1, 0, 0, allWordsTrieRoot, fromCharacterFrequencies, characterSubstitutionFrequencies); Double result = testCandidateWordPriorityCalculator.CalculatePriority("read", "lead", "toll", 20); Assert.AreEqual(1.0, result); }
public void CalculatePriority_SourceToCandidateDistanceMaximum() { testCandidateWordPriorityCalculator = new CandidateWordPriorityCalculator(20, 1, 0, 0, 0, allWordsTrieRoot, fromCharacterFrequencies, characterSubstitutionFrequencies); Double result = testCandidateWordPriorityCalculator.CalculatePriority("test", "best", "mall", 1); Assert.AreEqual(0.05, result); }
public void CalculatePriority_CurrentWord0Length() { ArgumentException e = Assert.ThrowsException <ArgumentException>(() => { testCandidateWordPriorityCalculator.CalculatePriority("", "test", "mall", 1); }); StringAssert.StartsWith(e.Message, "Parameter 'currentWord' must be greater than or equal to 1 character in length."); Assert.AreEqual("currentWord", e.ParamName); }
public void CalculatePriority_MixedPriorityWeights() { // Overall priority should be calculated as follows (see DataStructureUtilitiesTests.PopulateAdjacentWordDataStructures() test for a list of the expected contents of 'fromCharacterFrequencies' and 'characterSubstitutionFrequencies')... // CalculateSourceWordToCandidateWordDistancePriority() // distance = 5/20 = 0.25, weighting = 1/10 = 0.1, weighted priority = 0.025 // CalculateNumberOfCharactersMatchingDestinationPriority() // matching characters ('bead' and 'beat') = 3/4 = 0.75, weighting = 2/10 = 0.2, weighted priority = (1 - 0.75) * 0.2 = 0.05 // CalculatePopularityOfChangeToCharacterPriority() // changeTo character = 'b', popularity = 2/4 = 0.5, weighting = 3/10 = 0.3, weighted priority = (1 - 0.5) * 0.3 = 0.15 // CalculatePopularityOfCharacterChangePriority() // character substitution = 'r' > 'b', popularity = 1/2 = 0.5, weighting = 4/10 = 0.4, weighted priority = (1 - 0.5) * 0.4 = 0.2 // Total weighting = 0.025 + 0.05 + 0.15 + 0.2 = 0.425 testCandidateWordPriorityCalculator = new CandidateWordPriorityCalculator(20, 1, 2, 3, 4, allWordsTrieRoot, fromCharacterFrequencies, characterSubstitutionFrequencies); Double result = testCandidateWordPriorityCalculator.CalculatePriority("read", "bead", "beat", 5); Assert.AreEqual(0.425D, Math.Round(result, 4)); }