public InsertsPrePreprocessingAlgorithm(UniformPartsFinalResults upRows, RemovedTextElementsInfo insertsInfo, QuasiUPAttachmentFinalResults quasiUPs) : base(AlgorithmProcessingType.PreProcessing, AlgorithmObjectType.WholeSentence, AlgorithmNames.PreProcessing.Inserts, needPrintSourceData: false, needCopySentence: true) { _upRows = upRows; _insertsInfo = insertsInfo; _quasiUPs = quasiUPs; }
public InputSentence(FileStream input) { var xml = XDocument.Load(input); Id = xml.Root.Element(InputSentenceXMLConsts.NodeId).Value.Trim(); FIPKind = xml.Root.Element(InputSentenceXMLConsts.NodeFIPKind).Value.Trim(); EnumerationsGroupNr = xml.Root.Element(InputSentenceXMLConsts.NodeEnumerationsGroupNr).Value.Trim(); SPRBNr = xml.Root.Element(InputSentenceXMLConsts.NodeSPRBNr).Value.Trim(); InitialText = xml.Root.Element(InputSentenceXMLConsts.NodeInitialText).Value.Trim(); SentenceIndexInfo = new SentenceIndex(xml.Root.Element(InputSentenceXMLConsts.NodeIndexInfo)); RemovedTextElementsInfo = new RemovedTextElementsInfo(xml.Root.Element(InputSentenceXMLConsts.NodeTextElements)); _readTextElements(); Log.Info(LogInfo()); }
public InputSentence(string input) { Id = string.Empty; FIPKind = string.Empty; EnumerationsGroupNr = string.Empty; SPRBNr = string.Empty; InitialText = input; RemovedTextElementsInfo = new RemovedTextElementsInfo(); SentenceIndexInfo = new SentenceIndex("10000"); _readTextElements(); _processInserts(); if (RemovedTextElementsInfo.Any(x => x.Type == RemovedTextElementType.BeforeInsert)) { SentenceIndexInfo.Info2.Value = IndexInfoInserts.InsertsPresented.Value; } Log.Info(LogInfo()); }
private void _processInserts() { const string openBracket = "("; const string closeBracket = ")"; var openBracketCount = _textElements.Count(x => x == openBracket); var closedBracketCount = _textElements.Count(x => x == closeBracket); Debug.Assert(openBracketCount == closedBracketCount); Log.InfoFormat($"Обработка входящей строки предложения: значение до: '{InitialText}'"); // обрабатываем простой случай, когда нет вложенных скобок while (_textElements.Any(x => x == openBracket)) { var openBracketOrder = _textElements.IndexOf(openBracket); var closedBracketOrder = _textElements.IndexOf(closeBracket); Debug.Assert(closedBracketOrder > openBracketOrder); if (closedBracketOrder - openBracketOrder > 0) { var insertText = string.Join(" ", _textElements.Skip(openBracketOrder + 1).Take(closedBracketOrder - openBracketOrder - 1)); Log.InfoFormat($"Обработка входящей строки предложения: найдена вставка '{insertText}'."); SentenceIndexInfo.Info2 = IndexInfoInserts.InsertsPresented; RemovedTextElementsInfo = new RemovedTextElementsInfo(); var removedTextElementInfo = new RemovedTextElementInfo() { Type = RemovedTextElementType.BeforeInsert, ElementOrder = openBracketOrder, ElementsCount = closedBracketOrder - openBracketOrder }; RemovedTextElementsInfo.Add(removedTextElementInfo); Log.InfoFormat($"Создан объект вставки для '{GetInsertText(removedTextElementInfo)}'."); Log.InfoFormat($"Земена открывающей скобки '{_textElements[openBracketOrder - 1]} {_textElements[openBracketOrder]} {_textElements[openBracketOrder + 1]}' на запятую."); _textElements[openBracketOrder] = ","; _textElements.RemoveAt(closedBracketOrder); } InitialText = string.Join(" ", _textElements); _readTextElements(); } Log.InfoFormat($"Обработка входящей строки предложения: значение после: '{InitialText}'"); }
public InsertsFinalResults(Sentence sent, RemovedTextElementsInfo insertsInfo, SentenceElement outUPWord, SentenceElement outWord) { _items = new List<Insert>(); _helperData = new InsertsHelperData(); }