예제 #1
0
        public void TestExtractors()
        {
            Macroscope ms = new Macroscope();

            MacroscopeDataExtractorRegexes DataExtractor = new MacroscopeDataExtractorRegexes(Size: 5);

            List <string> Texts = new List <string> ();

            Texts.Add("The quick brown fox jumps over the lazy dog.");

            DataExtractor.SetRegex(0, "Label: The", @"\b([tT]he)\b");
            DataExtractor.SetRegex(1, "Label: over", @"\b([oO]ver)\b");
            DataExtractor.SetRegex(2, "Label: fox", @"\b([fF]ox)\b");
            DataExtractor.SetRegex(3, "Label: dog", @"\b([dD]og)\b");
            DataExtractor.SetRegex(4, "Label: brown", @"\b([bB]rown)\b");

            foreach (string ContainsText in Texts)
            {
                List <KeyValuePair <string,  string> > AnalyzedList = DataExtractor.AnalyzeText(Text: ContainsText);

                Assert.IsNotNull(AnalyzedList);

                foreach (KeyValuePair <string,  string> AnalyzedItem in AnalyzedList)
                {
                    ms.DebugMsg(string.Format("ITEM: {0} => \"{1}\"", AnalyzedItem.Key, AnalyzedItem.Value));
                }

                Assert.AreEqual(
                    6,
                    AnalyzedList.Count, // Should match 6 times
                    string.Format("Wrong number of matches: {0}", AnalyzedList.Count)
                    );
            }
        }
예제 #2
0
        public void TestExtractorsLong()
        {
            Macroscope ms = new Macroscope();

            MacroscopeDataExtractorRegexes DataExtractor = new MacroscopeDataExtractorRegexes(Size: 1);

            List <string> Texts = new List <string> ();

            Texts.Add("The quick brown fox jumps over the lazy dog.");

            DataExtractor.SetRegex(0, "Long:", "The (quick brown) fox jumps over the (lazy dog)");

            foreach (string ContainsText in Texts)
            {
                List <KeyValuePair <string,  string> > AnalyzedList = DataExtractor.AnalyzeText(Text: ContainsText);

                Assert.IsNotNull(AnalyzedList);

                foreach (KeyValuePair <string,  string> AnalyzedItem in AnalyzedList)
                {
                    ms.DebugMsg(string.Format("ITEM: {0} => \"{1}\"", AnalyzedItem.Key, AnalyzedItem.Value));
                }

                Assert.AreEqual(
                    2,
                    AnalyzedList.Count, // Should match 2 times
                    string.Format("Wrong number of matches: {0}", AnalyzedList.Count)
                    );
            }
        }