Ejemplo n.º 1
0
        public override void Init(Mediator mediator, XmlNode configurationParameters)
        {
            CheckDisposed();
            base.Init(mediator, configurationParameters);

            ComplexConcGroupNode pattern = (ComplexConcGroupNode)m_mediator.PropertyTable.GetValue("ComplexConcPattern");

            if (pattern == null)
            {
                pattern = new ComplexConcGroupNode();
                m_mediator.PropertyTable.SetProperty("ComplexConcPattern", pattern);
                m_mediator.PropertyTable.SetPropertyPersistence("ComplexConcPattern", false);
            }
            m_patternModel = new ComplexConcPatternModel(m_cache, pattern);

            m_view.Init(mediator, m_patternModel.Root.Hvo, this, new ComplexConcPatternVc(m_cache, mediator), ComplexConcPatternVc.kfragPattern,
                        m_patternModel.DataAccess);

            m_view.SelectionChanged     += SelectionChanged;
            m_view.RemoveItemsRequested += RemoveItemsRequested;
            m_view.ContextMenuRequested += ContextMenuRequested;

            m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Morph), CanAddMorph);
            m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Word), CanAddConstraint);
            m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.TextTag), CanAddConstraint);
            m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Or), CanAddOr);
            m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.WordBoundary), CanAddWordBoundary);
            UpdateViewHeight();
            m_view.RootBox.MakeSimpleSel(false, true, false, true);
        }
        public void GroupSearch()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcGroupNode {
                Minimum = 1, Maximum = 2, Children =
                {
                    new ComplexConcWordNode {
                        Category = m_verb
                    },
                    new ComplexConcOrNode(),
                    new ComplexConcWordNode {
                        Category = m_adj
                    }
                }
            });
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcGroupNode {
                Minimum = 1, Maximum = -1, Children =
                {
                    new ComplexConcWordNode         {
                        Category = m_verb
                    },
                    new ComplexConcGroupNode        {
                        Minimum = 0, Maximum = -1, Children =
                        {
                            new ComplexConcWordNode {
                                Category = m_adj
                            },
                            new ComplexConcOrNode(),
                            new ComplexConcWordNode {
                                Category = m_noun
                            }
                        }
                    },
                }
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 23, null) }).Using(m_fragmentComparer));
        }
        public void ParagraphWithInvalidParse()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            // cause analyses and baseline to get out-of-sync
            seg.AnalysesRS.RemoveAt(0);
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));
        }
        public void InvalidTags()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_verb
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            // create a tag that occurs after the segment
            ITextTag ttag = MakeTag(m_text, m_np, seg, 6, seg, 6);

            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            ttag.Delete();
            // create a tag where the begin index is greater than the end index
            MakeTag(m_text, m_np, seg, 5, seg, 4);
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));
        }
Ejemplo n.º 5
0
		public override void Init(Mediator mediator, XmlNode configurationParameters)
		{
			CheckDisposed();
			base.Init(mediator, configurationParameters);

			ComplexConcGroupNode pattern = (ComplexConcGroupNode) m_mediator.PropertyTable.GetValue("ComplexConcPattern");
			if (pattern == null)
			{
				pattern = new ComplexConcGroupNode();
				m_mediator.PropertyTable.SetProperty("ComplexConcPattern", pattern);
				m_mediator.PropertyTable.SetPropertyPersistence("ComplexConcPattern", false);
			}
			m_patternModel = new ComplexConcPatternModel(m_cache, pattern);

			m_view.Init(mediator, m_patternModel.Root.Hvo, this, new ComplexConcPatternVc(m_cache, mediator), ComplexConcPatternVc.kfragPattern,
				m_patternModel.DataAccess);

			m_view.SelectionChanged += SelectionChanged;
			m_view.RemoveItemsRequested += RemoveItemsRequested;
			m_view.ContextMenuRequested += ContextMenuRequested;

			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Morph), CanAddMorph);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Word), CanAddConstraint);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.TextTag), CanAddConstraint);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Or), CanAddOr);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.WordBoundary), CanAddWordBoundary);
			UpdateViewHeight();
			m_view.RootBox.MakeSimpleSel(false, true, false, true);
		}
        public void AlternationSearch()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_verb
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null), new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_verb
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null), new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcGroupNode {
                Children =
                {
                    new ComplexConcWordNode {
                        Category = m_verb
                    },
                    new ComplexConcOrNode(),
                    new ComplexConcWordNode {
                        Form = MakeVernString("yalola")
                    }
                }
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Gloss = MakeAnalysisString("green")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null), new ParaFragment(seg, 12, 15, null), new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcTagNode {
                Tag = m_np
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Gloss = MakeAnalysisString("green")
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 12, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcOrNode());
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_verb
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null), new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));
        }
        public void QuantifierSearch()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcWordNode {
                Minimum = 0, Maximum = -1
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 27, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcWordNode {
                Minimum = 0, Maximum = -1
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 27, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Gloss = MakeAnalysisString("1SgSubj")
            });
            model.Root.Children.Add(new ComplexConcMorphNode {
                Minimum = 1, Maximum = -1
            });
            model.Root.Children.Add(new ComplexConcMorphNode {
                Form = MakeVernString("ra")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_verb
            });
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_adj, Minimum = 0, Maximum = 1
            });
            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_verb, Minimum = 1, Maximum = 3
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_verb, Minimum = 1, Maximum = 4
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));
        }
        public void WordBoundarySearch()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcMorphNode {
                Form = MakeVernString("bili")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Form = MakeVernString("bili")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Form = MakeVernString("bili")
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_adj
            });
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_adj
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 12, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_adj
            });
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordBdryNode());
            model.Root.Children.Add(new ComplexConcMorphNode {
                Minimum = 0, Maximum = -1
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null),
                                                                                               new ParaFragment(seg, 12, 15, null), new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));
        }
        public void SimpleSearch()
        {
            var      para = (IStTxtPara)m_text.ContentsOA.ParagraphsOS.First();
            ISegment seg  = para.SegmentsOS.First();

            var model = new ComplexConcPatternModel(Cache);

            model.Root.Children.Add(new ComplexConcWordNode {
                Category = m_verb
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode {
                InflFeatures = {       { GetFeature("nounAgr"), new FS {
                                             { GetFeature("num"),     new ClosedFeatureValue(GetValue("sg"), false) }
                                         } } }
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode {
                InflFeatures = { { GetFeature("tense"), new ClosedFeatureValue(GetValue("pres"), true) } }
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 12, 15, null), new ParaFragment(seg, 17, 23, null), new ParaFragment(seg, 24, 27, null) }).Using(m_fragmentComparer));
            model.Root.Children.Clear();

            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_noun
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcTagNode {
                Tag = m_np
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 12, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null), new ParaFragment(seg, 12, 15, null), new ParaFragment(seg, 17, 23, null), new ParaFragment(seg, 24, 27, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Form = MakeVernString("him")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Entry = MakeVernString("ra")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Gloss = MakeAnalysisString("1SgPoss")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_adj, NegateCategory = true
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null), new ParaFragment(seg, 17, 23, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_adj, NegateCategory = true, Form = MakeVernString("him"), Entry = MakeVernString("him"), Gloss = MakeAnalysisString("3SgObj")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 11, null) }).Using(m_fragmentComparer));

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcMorphNode {
                Category = m_adj, NegateCategory = true, Form = MakeVernString("him"), Entry = MakeVernString("hin"), Gloss = MakeAnalysisString("3SgObj")
            });
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.Empty);

            model.Root.Children.Clear();
            model.Root.Children.Add(new ComplexConcWordNode());
            model.Root.Children.Add(new ComplexConcTagNode());
            model.Compile();
            Assert.That(model.Search(m_text.ContentsOA), Is.EquivalentTo(new IParaFragment[] { new ParaFragment(seg, 0, 23, null) }).Using(m_fragmentComparer));
        }
Ejemplo n.º 10
0
		public override void Init(Mediator mediator, XmlNode configurationParameters)
		{
			CheckDisposed();
			base.Init(mediator, configurationParameters);

			var pattern = (ComplexConcGroupNode) m_mediator.PropertyTable.GetValue("ComplexConcPattern");
			if (pattern == null)
			{
				pattern = new ComplexConcGroupNode();
				m_mediator.PropertyTable.SetProperty("ComplexConcPattern", pattern);
				m_mediator.PropertyTable.SetPropertyPersistence("ComplexConcPattern", false);
			}
			m_patternModel = new ComplexConcPatternModel(m_cache, pattern);

			m_view.Init(mediator, this);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Morph), CanAddMorph);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Word), CanAddConstraint);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.TextTag), CanAddConstraint);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.Or), CanAddOr);
			m_insertControl.AddOption(new InsertOption(ComplexConcordanceInsertType.WordBoundary), CanAddWordBoundary);
			UpdateViewHeight();
			m_view.RootBox.MakeSimpleSel(false, true, false, true);
		}