public void EmptyStringDoesNotThrow()
        {
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(3, 3);
            var             tssLabel      = m_tsf.EmptyString(WsDummy);

            Assert.IsFalse(rangeIntMatch.Matches(tssLabel));
        }
        public void OutOfRangeDoesNotThrow()
        {
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(3, 3);
            var             tssLabel      = m_tsf.MakeString("999999999999999999999999", WsDummy);

            Assert.IsFalse(rangeIntMatch.Matches(tssLabel));
        }
        public void DoesNotMatchIfNoneInListMatch()
        {
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(3, 3);
            var             tssLabel      = m_tsf.MakeString("0 1 2", WsDummy);

            Assert.IsFalse(rangeIntMatch.Matches(tssLabel));
        }
        public void MatchesIfOneInListMatches()
        {
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(2, 2);
            var             tssLabel      = m_tsf.MakeString("0 1 2", WsDummy);

            Assert.IsTrue(rangeIntMatch.Matches(tssLabel));
        }
        public void LongMaxValueTest()
        {
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(0, long.MaxValue);
            var             tssLabel      = m_tsf.MakeString("9223372036854775807", WsDummy);

            Assert.IsTrue(rangeIntMatch.Matches(tssLabel));
        }
Esempio n. 6
0
        /// <summary>
        /// True if it is the same class and member vars match.
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public override bool SameMatcher(IMatcher other)
        {
            RangeIntMatcher other2 = other as RangeIntMatcher;

            if (other2 == null)
            {
                return(false);
            }
            return(other2.m_min == m_min && other2.m_max == m_max);
        }
Esempio n. 7
0
		public void PersistMatchersEtc()
		{
			IWritingSystem defAnalWs = Cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem;
			// BaseMatcher is abstract
			// IntMatcher is abstract
			RangeIntMatcher rangeIntMatch = new RangeIntMatcher(5, 23);
			rangeIntMatch.WritingSystemFactory = Cache.WritingSystemFactory;
			ITsString tssLabel = Cache.TsStrFactory.MakeString("label1", defAnalWs.Handle);
			rangeIntMatch.Label = tssLabel;
			OwnIntPropFinder ownIntFinder = new OwnIntPropFinder(m_sda, 551);

			var rangeIntFilter = new FilterBarCellFilter(ownIntFinder, rangeIntMatch);
			m_objectsToDispose.Add(rangeIntFilter);
			AndFilter andFilter = new AndFilter();
			m_objectsToDispose.Add(andFilter);

			andFilter.Add(rangeIntFilter);

			ITsStrFactory tsf = Cache.TsStrFactory;
			int ws = defAnalWs.Handle;
			IVwPattern m_pattern = VwPatternClass.Create();
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;

			var otherFilter = new FilterBarCellFilter(ownIntFinder, new NotEqualIntMatcher(77));
			m_objectsToDispose.Add(otherFilter);

			andFilter.Add(otherFilter);

			OwnMlPropFinder mlPropFinder = new OwnMlPropFinder(m_sda, 788, 23);
			m_pattern.Pattern = tsf.MakeString("hello", ws);
			var filter = new FilterBarCellFilter(mlPropFinder, new ExactMatcher(m_pattern));
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			OwnMonoPropFinder monoPropFinder = new OwnMonoPropFinder(m_sda, 954);
			m_pattern = VwPatternClass.Create();
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
			m_pattern.Pattern = tsf.MakeString("goodbye", ws);
			filter = new FilterBarCellFilter(monoPropFinder, new BeginMatcher(m_pattern));
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			OneIndirectMlPropFinder oneIndMlPropFinder =
				new OneIndirectMlPropFinder(m_sda, 221, 222, 27);
			m_pattern = VwPatternClass.Create();
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
			m_pattern.Pattern = tsf.MakeString("exit", ws);
			filter = new FilterBarCellFilter(oneIndMlPropFinder, new EndMatcher(m_pattern));
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			MultiIndirectMlPropFinder mimlPropFinder = new MultiIndirectMlPropFinder(
				m_sda, new int[] {444, 555}, 666, 87);
			m_pattern = VwPatternClass.Create();
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
			m_pattern.Pattern = tsf.MakeString("whatever", ws);
			filter = new FilterBarCellFilter(mimlPropFinder, new AnywhereMatcher(m_pattern));
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			OneIndirectAtomMlPropFinder oneIndAtomFinder =
				new OneIndirectAtomMlPropFinder(m_sda, 543, 345, 43);
			filter = new FilterBarCellFilter(oneIndAtomFinder, new BlankMatcher());
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			filter = new FilterBarCellFilter(oneIndAtomFinder, new NonBlankMatcher());
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			m_pattern = VwPatternClass.Create();
			m_pattern.MatchOldWritingSystem = false;
			m_pattern.MatchDiacritics = false;
			m_pattern.MatchWholeWord = false;
			m_pattern.MatchCase = false;
			m_pattern.UseRegularExpressions = false;
			m_pattern.Pattern = tsf.MakeString("pattern", ws);
			filter = new FilterBarCellFilter(oneIndAtomFinder, new InvertMatcher(new RegExpMatcher(m_pattern)));
			m_objectsToDispose.Add(filter);
			andFilter.Add(filter);

			andFilter.Add(new NullFilter());

			XmlDocument docPaf = new XmlDocument();
			docPaf.LoadXml("<root targetClasses=\"LexEntry, LexSense\"></root>");
			ProblemAnnotationFilter paf = new ProblemAnnotationFilter();
			paf.Init(Cache, docPaf.DocumentElement);
			andFilter.Add(paf);

			// Save and restore!
			string xml = DynamicLoader.PersistObject(andFilter, "filter");

			XmlDocument doc = new XmlDocument();
			doc.LoadXml(xml);

			// And check all the pieces...
			var andFilterOut = DynamicLoader.RestoreObject(doc.DocumentElement) as AndFilter;
			m_objectsToDispose.Add(andFilterOut);
			andFilterOut.Cache = Cache;

			Assert.IsNotNull(andFilterOut);

			FilterBarCellFilter rangeIntFilterOut =
				andFilterOut.Filters[0] as FilterBarCellFilter;
			// todo
			Assert.IsNotNull(rangeIntFilterOut);

			OwnIntPropFinder ownIntFinderOut = rangeIntFilterOut.Finder as OwnIntPropFinder;
			Assert.IsNotNull(ownIntFinderOut);
			Assert.AreEqual(551, ownIntFinderOut.Flid);

			RangeIntMatcher rangeIntMatchOut = rangeIntFilterOut.Matcher as RangeIntMatcher;
			Assert.IsNotNull(rangeIntMatchOut);
			Assert.AreEqual(5, rangeIntMatchOut.Min);
			Assert.AreEqual(23, rangeIntMatchOut.Max);
			Assert.IsTrue(tssLabel.Equals(rangeIntMatchOut.Label));

			NotEqualIntMatcher notEqualMatchOut = GetMatcher(andFilter, 1) as NotEqualIntMatcher;
			Assert.IsNotNull(notEqualMatchOut);
			Assert.AreEqual(77, notEqualMatchOut.NotEqualValue);

			ExactMatcher exactMatchOut = GetMatcher(andFilter, 2) as ExactMatcher;
			Assert.IsNotNull(exactMatchOut);
			Assert.AreEqual("hello", exactMatchOut.Pattern.Pattern.Text);

			BeginMatcher beginMatchOut = GetMatcher(andFilter, 3) as BeginMatcher;
			Assert.IsNotNull(beginMatchOut);
			Assert.AreEqual("goodbye", beginMatchOut.Pattern.Pattern.Text);

			EndMatcher endMatchOut = GetMatcher(andFilter, 4) as EndMatcher;
			Assert.IsNotNull(endMatchOut);
			Assert.AreEqual("exit", endMatchOut.Pattern.Pattern.Text);

			AnywhereMatcher anywhereMatchOut = GetMatcher(andFilter, 5) as AnywhereMatcher;
			Assert.IsNotNull(anywhereMatchOut);
			Assert.AreEqual("whatever", anywhereMatchOut.Pattern.Pattern.Text);

			BlankMatcher blankMatchOut = GetMatcher(andFilter, 6) as BlankMatcher;
			Assert.IsNotNull(blankMatchOut);

			NonBlankMatcher nonBlankMatchOut = GetMatcher(andFilter, 7) as NonBlankMatcher;
			Assert.IsNotNull(nonBlankMatchOut);

			InvertMatcher invertMatchOut = GetMatcher(andFilter, 8) as InvertMatcher;
			Assert.IsNotNull(invertMatchOut);

			OwnMlPropFinder mlPropFinderOut = GetFinder(andFilter, 2) as OwnMlPropFinder;
			Assert.AreEqual(m_sda, mlPropFinderOut.DataAccess);
			Assert.AreEqual(788, mlPropFinderOut.Flid);
			Assert.AreEqual(23, mlPropFinderOut.Ws);

			OwnMonoPropFinder monoPropFinderOut = GetFinder(andFilter, 3) as OwnMonoPropFinder;
			Assert.AreEqual(m_sda, monoPropFinderOut.DataAccess);
			Assert.AreEqual(954, monoPropFinderOut.Flid);

			OneIndirectMlPropFinder oneIndMlPropFinderOut =
				GetFinder(andFilter, 4) as OneIndirectMlPropFinder;
			Assert.AreEqual(m_sda, oneIndMlPropFinderOut.DataAccess);
			Assert.AreEqual(221, oneIndMlPropFinderOut.FlidVec);
			Assert.AreEqual(222, oneIndMlPropFinderOut.FlidString);
			Assert.AreEqual(27, oneIndMlPropFinderOut.Ws);

			MultiIndirectMlPropFinder mimlPropFinderOut =
				GetFinder(andFilter, 5) as MultiIndirectMlPropFinder;
			Assert.AreEqual(m_sda, mimlPropFinderOut.DataAccess);
			Assert.AreEqual(444, mimlPropFinderOut.VecFlids[0]);
			Assert.AreEqual(555, mimlPropFinderOut.VecFlids[1]);
			Assert.AreEqual(666, mimlPropFinderOut.FlidString);
			Assert.AreEqual(87, mimlPropFinderOut.Ws);

			OneIndirectAtomMlPropFinder oneIndAtomFinderOut =
				GetFinder(andFilter, 6) as OneIndirectAtomMlPropFinder;
			Assert.AreEqual(m_sda, oneIndAtomFinderOut.DataAccess);
			Assert.AreEqual(543, oneIndAtomFinderOut.FlidAtom);
			Assert.AreEqual(345, oneIndAtomFinderOut.FlidString);
			Assert.AreEqual(43, oneIndAtomFinderOut.Ws);

			// 7, 8 are duplicates

			NullFilter nullFilterOut = andFilter.Filters[9] as NullFilter;
			Assert.IsNotNull(nullFilterOut);

			ProblemAnnotationFilter pafOut = andFilter.Filters[10] as ProblemAnnotationFilter;
			Assert.IsNotNull(pafOut);
			Assert.AreEqual(5002, pafOut.ClassIds[0]);
			Assert.AreEqual(5016, pafOut.ClassIds[1]);
		}
Esempio n. 8
0
        public void PersistMatchersEtc()
        {
            IWritingSystem defAnalWs = Cache.ServiceLocator.WritingSystems.DefaultAnalysisWritingSystem;
            // BaseMatcher is abstract
            // IntMatcher is abstract
            RangeIntMatcher rangeIntMatch = new RangeIntMatcher(5, 23);

            rangeIntMatch.WritingSystemFactory = Cache.WritingSystemFactory;
            ITsString tssLabel = Cache.TsStrFactory.MakeString("label1", defAnalWs.Handle);

            rangeIntMatch.Label = tssLabel;
            OwnIntPropFinder ownIntFinder = new OwnIntPropFinder(m_sda, 551);

            var rangeIntFilter = new FilterBarCellFilter(ownIntFinder, rangeIntMatch);

            m_objectsToDispose.Add(rangeIntFilter);
            AndFilter andFilter = new AndFilter();

            m_objectsToDispose.Add(andFilter);

            andFilter.Add(rangeIntFilter);

            ITsStrFactory tsf       = Cache.TsStrFactory;
            int           ws        = defAnalWs.Handle;
            IVwPattern    m_pattern = VwPatternClass.Create();

            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;

            var otherFilter = new FilterBarCellFilter(ownIntFinder, new NotEqualIntMatcher(77));

            m_objectsToDispose.Add(otherFilter);

            andFilter.Add(otherFilter);

            OwnMlPropFinder mlPropFinder = new OwnMlPropFinder(m_sda, 788, 23);

            m_pattern.Pattern = tsf.MakeString("hello", ws);
            var filter = new FilterBarCellFilter(mlPropFinder, new ExactMatcher(m_pattern));

            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            OwnMonoPropFinder monoPropFinder = new OwnMonoPropFinder(m_sda, 954);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("goodbye", ws);
            filter            = new FilterBarCellFilter(monoPropFinder, new BeginMatcher(m_pattern));
            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            OneIndirectMlPropFinder oneIndMlPropFinder =
                new OneIndirectMlPropFinder(m_sda, 221, 222, 27);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("exit", ws);
            filter            = new FilterBarCellFilter(oneIndMlPropFinder, new EndMatcher(m_pattern));
            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            MultiIndirectMlPropFinder mimlPropFinder = new MultiIndirectMlPropFinder(
                m_sda, new int[] { 444, 555 }, 666, 87);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("whatever", ws);
            filter            = new FilterBarCellFilter(mimlPropFinder, new AnywhereMatcher(m_pattern));
            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            OneIndirectAtomMlPropFinder oneIndAtomFinder =
                new OneIndirectAtomMlPropFinder(m_sda, 543, 345, 43);

            filter = new FilterBarCellFilter(oneIndAtomFinder, new BlankMatcher());
            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            filter = new FilterBarCellFilter(oneIndAtomFinder, new NonBlankMatcher());
            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            m_pattern = VwPatternClass.Create();
            m_pattern.MatchOldWritingSystem = false;
            m_pattern.MatchDiacritics       = false;
            m_pattern.MatchWholeWord        = false;
            m_pattern.MatchCase             = false;
            m_pattern.UseRegularExpressions = false;
            m_pattern.Pattern = tsf.MakeString("pattern", ws);
            filter            = new FilterBarCellFilter(oneIndAtomFinder, new InvertMatcher(new RegExpMatcher(m_pattern)));
            m_objectsToDispose.Add(filter);
            andFilter.Add(filter);

            andFilter.Add(new NullFilter());

            XmlDocument docPaf = new XmlDocument();

            docPaf.LoadXml("<root targetClasses=\"LexEntry, LexSense\"></root>");
            ProblemAnnotationFilter paf = new ProblemAnnotationFilter();

            paf.Init(Cache, docPaf.DocumentElement);
            andFilter.Add(paf);

            // Save and restore!
            string xml = DynamicLoader.PersistObject(andFilter, "filter");

            XmlDocument doc = new XmlDocument();

            doc.LoadXml(xml);

            // And check all the pieces...
            var andFilterOut = DynamicLoader.RestoreObject(doc.DocumentElement) as AndFilter;

            m_objectsToDispose.Add(andFilterOut);
            andFilterOut.Cache = Cache;

            Assert.IsNotNull(andFilterOut);

            FilterBarCellFilter rangeIntFilterOut =
                andFilterOut.Filters[0] as FilterBarCellFilter;

            // todo
            Assert.IsNotNull(rangeIntFilterOut);

            OwnIntPropFinder ownIntFinderOut = rangeIntFilterOut.Finder as OwnIntPropFinder;

            Assert.IsNotNull(ownIntFinderOut);
            Assert.AreEqual(551, ownIntFinderOut.Flid);

            RangeIntMatcher rangeIntMatchOut = rangeIntFilterOut.Matcher as RangeIntMatcher;

            Assert.IsNotNull(rangeIntMatchOut);
            Assert.AreEqual(5, rangeIntMatchOut.Min);
            Assert.AreEqual(23, rangeIntMatchOut.Max);
            Assert.IsTrue(tssLabel.Equals(rangeIntMatchOut.Label));

            NotEqualIntMatcher notEqualMatchOut = GetMatcher(andFilter, 1) as NotEqualIntMatcher;

            Assert.IsNotNull(notEqualMatchOut);
            Assert.AreEqual(77, notEqualMatchOut.NotEqualValue);

            ExactMatcher exactMatchOut = GetMatcher(andFilter, 2) as ExactMatcher;

            Assert.IsNotNull(exactMatchOut);
            Assert.AreEqual("hello", exactMatchOut.Pattern.Pattern.Text);

            BeginMatcher beginMatchOut = GetMatcher(andFilter, 3) as BeginMatcher;

            Assert.IsNotNull(beginMatchOut);
            Assert.AreEqual("goodbye", beginMatchOut.Pattern.Pattern.Text);

            EndMatcher endMatchOut = GetMatcher(andFilter, 4) as EndMatcher;

            Assert.IsNotNull(endMatchOut);
            Assert.AreEqual("exit", endMatchOut.Pattern.Pattern.Text);

            AnywhereMatcher anywhereMatchOut = GetMatcher(andFilter, 5) as AnywhereMatcher;

            Assert.IsNotNull(anywhereMatchOut);
            Assert.AreEqual("whatever", anywhereMatchOut.Pattern.Pattern.Text);

            BlankMatcher blankMatchOut = GetMatcher(andFilter, 6) as BlankMatcher;

            Assert.IsNotNull(blankMatchOut);

            NonBlankMatcher nonBlankMatchOut = GetMatcher(andFilter, 7) as NonBlankMatcher;

            Assert.IsNotNull(nonBlankMatchOut);

            InvertMatcher invertMatchOut = GetMatcher(andFilter, 8) as InvertMatcher;

            Assert.IsNotNull(invertMatchOut);

            OwnMlPropFinder mlPropFinderOut = GetFinder(andFilter, 2) as OwnMlPropFinder;

            Assert.AreEqual(m_sda, mlPropFinderOut.DataAccess);
            Assert.AreEqual(788, mlPropFinderOut.Flid);
            Assert.AreEqual(23, mlPropFinderOut.Ws);

            OwnMonoPropFinder monoPropFinderOut = GetFinder(andFilter, 3) as OwnMonoPropFinder;

            Assert.AreEqual(m_sda, monoPropFinderOut.DataAccess);
            Assert.AreEqual(954, monoPropFinderOut.Flid);

            OneIndirectMlPropFinder oneIndMlPropFinderOut =
                GetFinder(andFilter, 4) as OneIndirectMlPropFinder;

            Assert.AreEqual(m_sda, oneIndMlPropFinderOut.DataAccess);
            Assert.AreEqual(221, oneIndMlPropFinderOut.FlidVec);
            Assert.AreEqual(222, oneIndMlPropFinderOut.FlidString);
            Assert.AreEqual(27, oneIndMlPropFinderOut.Ws);

            MultiIndirectMlPropFinder mimlPropFinderOut =
                GetFinder(andFilter, 5) as MultiIndirectMlPropFinder;

            Assert.AreEqual(m_sda, mimlPropFinderOut.DataAccess);
            Assert.AreEqual(444, mimlPropFinderOut.VecFlids[0]);
            Assert.AreEqual(555, mimlPropFinderOut.VecFlids[1]);
            Assert.AreEqual(666, mimlPropFinderOut.FlidString);
            Assert.AreEqual(87, mimlPropFinderOut.Ws);

            OneIndirectAtomMlPropFinder oneIndAtomFinderOut =
                GetFinder(andFilter, 6) as OneIndirectAtomMlPropFinder;

            Assert.AreEqual(m_sda, oneIndAtomFinderOut.DataAccess);
            Assert.AreEqual(543, oneIndAtomFinderOut.FlidAtom);
            Assert.AreEqual(345, oneIndAtomFinderOut.FlidString);
            Assert.AreEqual(43, oneIndAtomFinderOut.Ws);

            // 7, 8 are duplicates

            NullFilter nullFilterOut = andFilter.Filters[9] as NullFilter;

            Assert.IsNotNull(nullFilterOut);

            ProblemAnnotationFilter pafOut = andFilter.Filters[10] as ProblemAnnotationFilter;

            Assert.IsNotNull(pafOut);
            Assert.AreEqual(5002, pafOut.ClassIds[0]);
            Assert.AreEqual(5016, pafOut.ClassIds[1]);
        }