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)); }
protected override List <IParaFragment> SearchForMatches() { List <IParaFragment> matches = new List <IParaFragment>(); if (m_patternModel.IsPatternEmpty) { return(matches); } using (new WaitCursor(this)) { m_patternModel.Compile(); ParseUnparsedParagraphs(); foreach (IStText text in ConcDecorator.InterestingTexts) { matches.AddRange(m_patternModel.Search(text)); if (m_patternModel.CouldNotParseAllParagraphs) { MessageBox.Show(string.Format(ITextStrings.ComplexConcControl_NotAllParasParsed, text.ChooserNameTS.Text), ITextStrings.ComplexConcControl_ResultsMayBeIncomplete, MessageBoxButtons.OK, MessageBoxIcon.Warning); } } } return(matches); }
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)); }
protected override List <IParaFragment> SearchForMatches() { List <IParaFragment> matches = new List <IParaFragment>(); if (m_patternModel.IsPatternEmpty) { return(matches); } using (new WaitCursor(this)) { m_patternModel.Compile(); ParseUnparsedParagraphs(); foreach (IStText text in ConcDecorator.InterestingTexts) { matches.AddRange(m_patternModel.Search(text)); } } return(matches); }
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)); }
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)); }