public void TestContainsRegex() { MacroscopeCustomFilters CustomFilter = new MacroscopeCustomFilters(Size: 5); List <string> Texts = new List <string>(); Texts.Add("The quick brown fox jumps over the lazy dog."); CustomFilter.SetPattern(0, "Th[e]", MacroscopeConstants.Contains.MUST_HAVE_REGEX); CustomFilter.SetPattern(1, "[Oo]ver", MacroscopeConstants.Contains.MUST_HAVE_REGEX); CustomFilter.SetPattern(2, "[a-z]{2}x", MacroscopeConstants.Contains.MUST_HAVE_REGEX); CustomFilter.SetPattern(3, "(dog|DOG)", MacroscopeConstants.Contains.MUST_HAVE_REGEX); CustomFilter.SetPattern(4, "^.+brown.+$", MacroscopeConstants.Contains.MUST_HAVE_REGEX); foreach (string ContainsText in Texts) { Dictionary <string, MacroscopeConstants.TextPresence> Analyzed = CustomFilter.AnalyzeText(Text: ContainsText); Assert.IsNotNull(Analyzed); foreach (string AnalyzedKey in Analyzed.Keys) { Assert.AreEqual( MacroscopeConstants.TextPresence.CONTAINS_REGEX, Analyzed[AnalyzedKey], string.Format( "Wrong TextPresence for: {0} :: {1}", AnalyzedKey, Analyzed[AnalyzedKey] ) ); } } }
public void TestDoesNotContainText() { MacroscopeCustomFilters CustomFilter = new MacroscopeCustomFilters(Size: 5); List <string> Texts = new List <string> (); Texts.Add("The quick brown fox jumps over the lazy dog."); CustomFilter.SetPattern(0, "Mad", MacroscopeConstants.Contains.MUST_NOT_HAVE_STRING); CustomFilter.SetPattern(1, "car", MacroscopeConstants.Contains.MUST_NOT_HAVE_STRING); CustomFilter.SetPattern(2, "nugget", MacroscopeConstants.Contains.MUST_NOT_HAVE_STRING); CustomFilter.SetPattern(3, "quickly", MacroscopeConstants.Contains.MUST_NOT_HAVE_STRING); CustomFilter.SetPattern(4, "doggy", MacroscopeConstants.Contains.MUST_NOT_HAVE_STRING); foreach (string ContainsText in Texts) { Dictionary <string, MacroscopeConstants.TextPresence> Analyzed = CustomFilter.AnalyzeText(Text: ContainsText); Assert.IsNotNull(Analyzed); foreach (string AnalyzedKey in Analyzed.Keys) { Assert.AreEqual( MacroscopeConstants.TextPresence.NOT_CONTAINS_STRING, Analyzed[AnalyzedKey], string.Format( "Wrong TextPresence for: {0} :: {1}", AnalyzedKey, Analyzed[AnalyzedKey] ) ); } } }
/** Process Custom Filtered ***********************************************/ private void ProcessGenericCustomFiltered( MacroscopeCustomFilters CustomFilter, string GenericText ) { Dictionary <string, MacroscopeConstants.TextPresence> Analyzed; Analyzed = CustomFilter.AnalyzeText(Text: GenericText); foreach (string Key in Analyzed.Keys) { this.SetCustomFiltered(Text: Key, Presence: Analyzed[Key]); } }