public void TestEditDistanceMatching() { SearchResultList <String> results = _stringMatcher.Search("01234", 1); Assert.AreEqual(3, results.Count); Assert.IsTrue(results.ContainsKeyword("01234")); Assert.IsTrue(results.ContainsKeyword("0123")); Assert.IsTrue(results.ContainsKeyword("012345")); }
public void TestSeventyFivePercentMatching() { SearchResultList <String> results = _stringMatcher.Search("0123456789", 75.0f); Assert.AreEqual(3, results.Count); Assert.IsTrue(results.ContainsKeyword("0123456789")); Assert.IsTrue(results.ContainsKeyword("012345678")); Assert.IsTrue(results.ContainsKeyword("01234567")); }
public void TestTwentyFivePercentMatching() { SearchResultList <String> results = _stringMatcher.Search("0123456789", 25.0f); Assert.AreEqual(9, results.Count); Assert.IsTrue(results.ContainsKeyword("0123456789")); Assert.IsTrue(results.ContainsKeyword("012345678")); Assert.IsTrue(results.ContainsKeyword("01234567")); Assert.IsTrue(results.ContainsKeyword("0123456")); Assert.IsTrue(results.ContainsKeyword("012345")); Assert.IsTrue(results.ContainsKeyword("01234")); Assert.IsTrue(results.ContainsKeyword("0123")); Assert.IsTrue(results.ContainsKeyword("012")); // C# rounding will cause an extra result compared to the Java implementation Assert.IsTrue(results.ContainsKeyword("01")); }
public void TestIgnoreLinebreaks() { StringMatcher <String> ignoreLinebreaksMatcher = new StringMatcher <String>(MatchingOption.RemoveSpacingAndLinebreaks); ignoreLinebreaksMatcher.Add("This has\nsome line\nbreaks.", "A string with linebreaks"); SearchResultList <String> results = ignoreLinebreaksMatcher.Search("This has some line breaks.", 100.0f); Assert.AreEqual(1, results.Count); Assert.IsTrue(results.ContainsKeyword("This has\nsome line\nbreaks.")); }
public void TestIgnoreTabs() { StringMatcher <String> ignoreTabsMatcher = new StringMatcher <String>(MatchingOption.RemoveSpacingAndLinebreaks); ignoreTabsMatcher.Add("\t\tThis is some tabbed data", "A string with tabs"); SearchResultList <String> results = ignoreTabsMatcher.Search("This is some tabbed \tdata", 100.0f); Assert.AreEqual(1, results.Count); Assert.IsTrue(results.ContainsKeyword("\t\tThis is some tabbed data")); }
public void TestFiftyPercentMatching() { SearchResultList <String> results = _stringMatcher.Search("0123456789", 50.0f); Assert.AreEqual(6, results.Count); Assert.IsTrue(results.ContainsKeyword("0123456789")); Assert.IsTrue(results.ContainsKeyword("012345678")); Assert.IsTrue(results.ContainsKeyword("01234567")); Assert.IsTrue(results.ContainsKeyword("0123456")); Assert.IsTrue(results.ContainsKeyword("012345")); Assert.IsTrue(results.ContainsKeyword("01234")); }
public void TestMultipleWords() { SearchResultList <String> results = _stringMatcher.Search("This is a vest", 90.0f); Assert.IsTrue(results.ContainsKeyword("This is a test")); }
public void TestCaseSensitive() { SearchResultList <String> results = _stringMatcher.Search("cat", 100.0f); Assert.IsTrue(results.ContainsKeyword("Cat")); }