public IEnumerable <IParaFragment> Search(IStText text) { CouldNotParseAllParagraphs = false; if (IsPatternEmpty) { return(Enumerable.Empty <IParaFragment>()); } var matches = new List <IParaFragment>(); foreach (IStTxtPara para in text.ParagraphsOS.OfType <IStTxtPara>()) { try { IParaFragment lastFragment = null; var data = new ComplexConcParagraphData(m_spanFactory, m_featSys, para); Match <ComplexConcParagraphData, ShapeNode> match = m_matcher.Match(data); while (match.Success) { if (match.Span.Start == match.Span.End && ((FeatureSymbol)match.Span.Start.Annotation.FeatureStruct .GetValue <SymbolicFeatureValue>("type")).ID == "bdry") { match = match.NextMatch(); continue; } ShapeNode startNode = match.Span.Start; if (((FeatureSymbol)startNode.Annotation.FeatureStruct .GetValue <SymbolicFeatureValue>("type")).ID == "bdry") { startNode = startNode.Next; } Annotation <ShapeNode> startAnn = startNode.Annotation; if (((FeatureSymbol)startAnn.FeatureStruct.GetValue <SymbolicFeatureValue>( "type")).ID == "morph") { startAnn = startAnn.Parent; } var startAnalysis = (Tuple <IAnalysis, int, int>)startAnn.Data; ShapeNode endNode = match.Span.End; if (((FeatureSymbol)endNode.Annotation.FeatureStruct .GetValue <SymbolicFeatureValue>("type")).ID == "bdry") { endNode = endNode.Prev; } Annotation <ShapeNode> endAnn = endNode.Annotation; if (((FeatureSymbol)endAnn.FeatureStruct.GetValue <SymbolicFeatureValue>( "type")).ID == "morph") { endAnn = endAnn.Parent; } Debug.Assert(startNode.CompareTo(endNode) <= 0); var endAnalysis = (Tuple <IAnalysis, int, int>)endAnn.Data; if (lastFragment != null && lastFragment.GetMyBeginOffsetInPara() == startAnalysis.Item2 && lastFragment.GetMyEndOffsetInPara() == endAnalysis.Item3) { match = GetNextMatch(match); continue; } ISegment seg = para.SegmentsOS.Last(s => s.BeginOffset <= startAnalysis.Item2); lastFragment = new ParaFragment(seg, startAnalysis.Item2, endAnalysis.Item3, startAnalysis.Item1); matches.Add(lastFragment); match = GetNextMatch(match); } } catch (InvalidOperationException) { CouldNotParseAllParagraphs = true; } } return(matches); }