private bool _getIsAttachmentType1(SentenceElement el) { return el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.Specification_Address || el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.NominalPostModBracket || el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.NominalPostMod_Colon || el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.NominalPostMod_Dash || el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.AdditionalComponentControlled || el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.Apposition ; }
/// <summary> /// Актуализиарует или добавляет ОЧ в существующий или новый ряд ОЧ. На значения параметров наложены условия на опциональный запрет обновления. /// </summary> /// <param name="uniformPart">Элемент предложения</param> /// <param name="rowNr">Номер ряда, если пустой - обновления не происходит</param> /// <param name="featureLinkConjunction">ПС СС, если = 0 - обновления не происходит</param> /// <param name="featureLinkComma">ПС З, если = 0 - обновления не происходит</param> public void AddOrUpdateUniformPart(SentenceElement uniformPart, string rowNr, int featureLinkConjunction, int featureLinkComma) { Log.DebugFormat($"[{Type}]Старт актуализации"); if (Type == AlgorithmActiveLOType.UniformPartsStandart) _addOrUpdateStandartUniformPart(uniformPart, rowNr); else if (Type == AlgorithmActiveLOType.UniformPartsBaseRows) _addOrUpdateBaseOrFinalRowsUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); else if (Type == AlgorithmActiveLOType.UniformParts) _addOrUpdateBaseOrFinalRowsUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); }
private bool _isCommaReplacementNeeded(SentenceElement mainEnumerationWord, SentenceElement firstChildWord, BaseSentenceAlgorithmData result) { var needComma = false; if (mainEnumerationWord.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Noun.Value && firstChildWord.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Participle.Value) { Log.Debug("АПР2. Существительное + причастие"); needComma= true; } if (mainEnumerationWord.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Verb.Value && firstChildWord.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Participle.Value) { Log.Debug("АПР2. Глагол + Деепричастие"); needComma= true; } var hasFirstChildWordPreposition = result.Sentence.SyntacticChildren(firstChildWord) .Find(x => x.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Preposition.Value) != null; if (mainEnumerationWord.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Noun.Value && firstChildWord.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Noun.Value) { if (mainEnumerationWord.GrammarInfo.Case == firstChildWord.GrammarInfo.Case && hasFirstChildWordPreposition) { Log.Debug("АПР2. Существительное в падеже X + существительное в падеже Х без предлога"); needComma= true; } } result.HelperData.Rows.Add(Guid.NewGuid().ToString(), -1, string.Empty, mainEnumerationWord.Text, mainEnumerationWord.GrammarInfo.PartOfSpeech, mainEnumerationWord.GrammarInfo.Case, firstChildWord.Text, firstChildWord.GrammarInfo.PartOfSpeech, firstChildWord.GrammarInfo.Case, hasFirstChildWordPreposition, needComma); return needComma; }
public void AddOrUpdateSingleRootPredicate(SentenceElement candidate, PredicateType type) { var existingPredicate = All. FindAll(x => x.PredicateType == PredicateType.Predicate || x.PredicateType == PredicateType.Phantom). FindAll(x => x.Id == candidate?.Id); if (existingPredicate.Count > 0) return; Log.InfoFormat($"Актуализация: добаляем новое корневое сказуемое: Id = {candidate.Id}; Text = {candidate.Text}"); Items.Add(new List<PredicatePartHelperObject>() { new PredicatePartHelperObject( candidate.GUID, candidate.Text, candidate.Id, candidate.Order, -1, PredicateType.Predicate.ToString(), -1, 0, PredicatePartType.Root.ToString(), string.Empty, false) } ); }
private object[] _processParticiple(SentenceElement element, Sentence sentence, UniformPartsFinalResults upRows) { var participleId = element.Id; var hasChildrenNotServicePart = sentence.SyntacticChildren(participleId).Any(x => x.SyntacticRole.Value != SyntacticRole.ParticleNegative.Value && x.SyntacticRole.Value != SyntacticRole.CoordinatingConjunction.Value && x.SyntacticRole.Value != SyntacticRole.Particle.Value); if (hasChildrenNotServicePart) { Log.InfoFormat(" Обнаружили потомка не СЧР. Причастие -- Причастие Финальное 1"); var finalParticiple1 = participleId; return new object[] {participleId, finalParticiple1, -1, finalParticiple1, -1}; } Log.InfoFormat("Причастие - Причастие - предварительное 2)"); if (!upRows.All.Any(x => x.Id == participleId)) { Log.InfoFormat(" Причастие не принадлежит ни одному из рядов. Причастие -- Признак 1"); var participleFeature = participleId; return new object[] {participleId, -1, -1, -1, participleFeature}; } var rowNr = upRows.All.Find(x => x.Id == participleId).RowNr; Log.InfoFormat(" Причастие принадлежит к ряду ОЧ {0}. Причастие - предваритиельное 3", rowNr); if (sentence.Elements.FindAll(x => upRows.All.Select(y => y.Id).Contains(x.SyntacticParentWordId)).Any(x => x.SyntacticRole.Value != SyntacticRole.ParticleNegative.Value && x.SyntacticRole.Value != SyntacticRole.CoordinatingConjunction.Value && x.SyntacticRole.Value != SyntacticRole.Particle.Value)) { Log.InfoFormat(" У сочиненных с рассматриваемым причастий нет потомков не СЧР. Причастие -- Признак 2"); var participleFeature = participleId; return new object[] { participleId, -1, -1, -1, participleFeature }; } else { Log.InfoFormat(" У сочиненных с рассматриваемым причастий есть хотя бы один потомок не СЧР. Причастие -- Финальное 2"); var participleFinal2 = participleId; return new object[] { participleId, -1, participleFinal2, participleFinal2, -1 }; } }
public void AddOrUpdateUniformPart(SentenceElement uniformPart, string rowNr, int featureLinkConjunction, int featureLinkComma, AlgorithmActiveLOType upType) { Debug.Assert(upType == AlgorithmActiveLOType.UniformParts || upType == AlgorithmActiveLOType.UniformPartsStandart || upType == AlgorithmActiveLOType.UniformPartsBaseRows); if (upType == AlgorithmActiveLOType.UniformPartsStandart) { _finalResults.UniformPartsFinalResultsStandart.AddOrUpdateUniformPart(uniformPart, rowNr, -1, -1); _finalResults.UniformPartsFinalResultsBaseRows.AddOrUpdateUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); _finalResults.UniformPartsFinalResults.AddOrUpdateUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); } else if (upType == AlgorithmActiveLOType.UniformPartsBaseRows) { _finalResults.UniformPartsFinalResultsBaseRows.AddOrUpdateUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); _finalResults.UniformPartsFinalResults.AddOrUpdateUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); } else if (upType == AlgorithmActiveLOType.UniformParts) _finalResults.UniformPartsFinalResults.AddOrUpdateUniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); }
private void _addOrUpdateBaseOrFinalRowsUniformPart(SentenceElement uniformPart, string rowNr, int featureLinkConjunction, int featureLinkComma) { // если ряд неизвестен, то это эквивалентно добавление стандартного ОЧ if (rowNr == UnknownRowNr) { Log.DebugFormat($"[{Type}]Актуализация: ряд неизвестен, добавляем как стандартный ОЧ"); _addOrUpdateStandartUniformPart(uniformPart, rowNr); return; } // когда добавляем ОЧ с наличием признака ряда, то старый надо удалить из ряда "-1" var uniformPartInUnknownRow = All.Find(x => x.Id == uniformPart.Id && x.RowNr == UnknownRowNr); if (rowNr != UnknownRowNr && uniformPartInUnknownRow != null) { Log.DebugFormat( $"[{Type}]Актуализация: удаление существующего ОЧ с Id = {uniformPartInUnknownRow.Id} и рядом {uniformPartInUnknownRow.RowNr}"); RemoveUniformPart(uniformPartInUnknownRow.Id, false); } List<UniformPart> uniformPartElements = new List<UniformPart>(); // если надо обновить инфу об ОЧ во всех рядах (rowNr == string.Empty) if (rowNr == string.Empty) uniformPartElements.AddRange(All.FindAll(x => x.Id == uniformPart.Id)); else // обычная ситуация uniformPartElements = All.FindAll(x => x.Id == uniformPart.Id && x.RowNr == rowNr); // ОЧ с комбинацией Id-RowNr уже существует if (uniformPartElements.Count > 0) { foreach (var uniformPartElement in uniformPartElements) { if ((uniformPartElement.RowNr != rowNr) || (uniformPartElement.RowNr == rowNr) || uniformPartElement.FeatureLinkComma != featureLinkComma || uniformPartElement.FeatureLinkConjunction != featureLinkConjunction) { Log.DebugFormat( $"[{Type}]Возможная актуализация: Обновление ОЧ с Id = {uniformPartElement.Id}, Текст = {uniformPartElement.Text}, Ряд = {rowNr}"); if (rowNr != string.Empty) { uniformPartElement.RowNr = rowNr; Log.Debug($"[{Type}]Обновлен Ряд: {rowNr}"); } if (featureLinkComma != 0) { uniformPartElement.FeatureLinkComma = featureLinkComma; Log.Debug($"[{Type}]Обновлен ПС Запятая: {featureLinkComma}"); } if (featureLinkConjunction != 0) { uniformPartElement.FeatureLinkConjunction = featureLinkConjunction; Log.Debug($"[{Type}]Обновлен ПС Союз: {featureLinkConjunction}"); } } } } // // ОЧ с комбинацией Id-RowNr НЕ существует else { // если надо создать ряд с пустым номером ряда, то расцениваем это как создание ОЧ с № = -1. if (rowNr == string.Empty) rowNr = UnknownRowNr; var uniformPartNewElement = new UniformPart(uniformPart, rowNr, featureLinkConjunction, featureLinkComma); Log.DebugFormat( $"[{Type}]Актуализация: Создание нового ОЧ: Id = {uniformPartNewElement.Id}, Текст = {uniformPartNewElement.Text}"); if (rowNr != string.Empty) { // проверяем, нет ли уже объектов рядов с номером ряда, как у добавляемого if (All.Any(x => x.RowNr == rowNr)) { Log.DebugFormat( $"[{Type}]Актуализация: Добавляем ОЧ с Id = {uniformPartNewElement.Id} в ряд с номером '{rowNr}'"); // добавляем его в объект того ряда, куда он входит, если таковых еще нет. if (All.Find(x => x.RowNr == uniformPartNewElement.RowNr && x.Id == uniformPartNewElement.Id) == null) { Items.ToList() .Find(x => x.Values.Select(y => y.RowNr).Contains(rowNr)) .Add(uniformPartNewElement.Order, uniformPartNewElement); } } else { // если рядов не нашлось, то создаем новый ряд и добавляем туда наш элемент var uniformPartsNewRow = new UniformPartRow { {uniformPartNewElement.Order, uniformPartNewElement} }; Log.DebugFormat($"[{Type}]Актуализация: Сформирован новый ряд ОЧ с номером '{rowNr}'"); // добавляем ряд к результатам Items.Add(uniformPartsNewRow); } } } if (_needToMerge) _mergeRows(); }
private bool _getCanJoinAnotherInfinitive(List<PredicatePartHelperObject> sourceElemets, int elementId, SentenceElement sentenceElement) { var possibleCommonclassValues = new[] { SemanticInfoCommonClass.ToWant.Value , SemanticInfoCommonClass.Modal.Value , SemanticInfoCommonClass.ToPromise.Value , SemanticInfoCommonClass.ToInstructAndOrder.Value , SemanticInfoCommonClass.ToAllow.Value , SemanticInfoCommonClass.ToCompel.Value , SemanticInfoCommonClass.InternalAbility.Value , SemanticInfoCommonClass.BeginToTakePlace.Value , SemanticInfoCommonClass.ContinueToTakePlace.Value , SemanticInfoCommonClass.EndToTakePlace.Value , SemanticInfoCommonClass.MakeEfforts.Value }; var hasGoodCommonClass = possibleCommonclassValues.Contains(sentenceElement.SemanticInfo.CommonClass.Value); var hasChildren = sourceElemets.FindAll(x => x.PartParentId == elementId && x.PartType == PredicatePartType.Infinitive).Count > 0; return hasGoodCommonClass && !hasChildren; }
private static void AddElement(SentenceElement item, string groupNr, ref int upCounter, QuasiUniformPartsMainHelperData resultHelpData) { resultHelpData.AddOrUpdateCustomRow(item.GUID, item.Id, groupNr, item.Id, upCounter); Log.InfoFormat("Добавили элемент: id = {0}; Text = {1}; Surface slot = {2}; Syntactic Role = {3}; case = {4}", item.Id, item.Text, item.SurfaceSlot, item.SyntacticRole.Value, item.GrammarInfo.Case.Value); }
private bool _getIsAttachmentType2(SentenceElement el) { return el.SurfaceSlot == Consts.SurfaceSlotDefinedValues.NominalPostModSpec; }
public QuasiUPAttachmentHelperObject(SentenceElement el) { el.CopyInto(this); }
public void AddOrUpdateSubject(SentenceElement subject, SubjectClass @class, ObjectSubstantivatorType subtype, int? aId, int? bId) { var subjectPartElement = All.Find(x => x.WordId == subject.Id); if (subjectPartElement != null) { Log.DebugFormat($"Актуализация: Обновление ОЧ с Id = {subjectPartElement.WordId}, Текст = {subjectPartElement.Text}"); subjectPartElement.GUID = subject.GUID; subjectPartElement.WordId = subject.Id; subjectPartElement.Class = @class; subjectPartElement.Subtype = subtype; subjectPartElement.Text = subject.Text; var normalAId = aId ?? (subjectPartElement.AId == -1 ? -1 : subjectPartElement.AId); var normalBId = bId ?? (subjectPartElement.BId == -1 ? -1 : subjectPartElement.BId); subjectPartElement.AId = normalAId; subjectPartElement.BId = normalBId; } else { var normalAId = aId ?? -1; var normalBId = bId ?? -1; subjectPartElement = new SubjectFinalResult() { GUID = subject.GUID , AId = normalAId , BId = normalBId , WordId = subject.Id , Class = @class , Subtype = subtype , Text = subject.Text }; All.Add(subjectPartElement); } }
public InsertsFinalResults(Sentence sent, RemovedTextElementsInfo insertsInfo, SentenceElement outUPWord, SentenceElement outWord) { _items = new List<Insert>(); _helperData = new InsertsHelperData(); }
/// <summary> /// Добавляем в предложение новое слово. Слово для добавления уже должно быть создано и иметь значение свойства Order для постановки на свое целевое место /// </summary> /// <param name="element">Созданный элемент предложения для вставки</param> public void AddWord(SentenceElement element) { var elementBeforeInsert = Elements.Find(x => x.Order == element.Order - 1); var insertOrder = elementBeforeInsert != null ? Elements.IndexOf(elementBeforeInsert) + 1 : 0; Log.InfoFormat("Вставляем слово в предложение. Id = {0}, Order = {1}, Текст = {2}.", element.Id, element.Order, element.Text); Log.InfoFormat("Слова +/- 2 от вставляемого: '{0}'", string.Join(" ", Elements.FindAll(x => Math.Abs(x.Order - element.Order) <= 2).Select(x => x.Text))); Elements.FindAll(x => x.Order >= element.Order).ForEach(x => x.Order = x.Order + 1); Elements.Insert(insertOrder, SentenceElement.Copy(element)); Log.InfoFormat("После вставки: '{0}'", string.Join(" ", Elements.FindAll(x => Math.Abs(x.Order - element.Order) <= 2).Select(x => x.Text))); }
public List<SentenceElement> LeftConjuntedElements(SentenceElement el) { Debug.Assert(el != null ); var result = new List<SentenceElement>(); var currentElement = Elements.Find(x => x.ConjunctedWithGUID == el.GUID); while (currentElement != null) { result.Add(currentElement); currentElement = Elements.Find(x => x.ConjunctedWithGUID == currentElement.GUID); } return result; }
public void CopyInto(SentenceElement destItem) { destItem.XML = XML; destItem.SyntacticChain = SyntacticChain.DeepCopy(); destItem.UniformLinkChain = UniformLinkChain.DeepCopy(); destItem.GUID = GUID; destItem.Id = Id; destItem.Position = Position; destItem.Order = Order; destItem.Text = _text; destItem.ElementType = SentenceElementType.ReadFromString(ElementType.Value); destItem.Lemma = Lemma; destItem.SyntacticRole = SyntacticRole.ReadFromString(SyntacticRole.Value); destItem.SurfaceSlot = SurfaceSlot; destItem.IsRestored = IsRestored; destItem.SyntacticParentWordGUID = SyntacticParentWordGUID; destItem.SyntacticParentWordId = SyntacticParentWordId; destItem.ControllerNodes = ControllerNodes.ConvertAll( x => new Controller(x.ConnectionType.Value, x.OriginalText, x.OriginalWordGUID)); destItem.ConjunctedWithGUID = ConjunctedWithGUID; destItem.ConjunctedWithId = ConjunctedWithId; destItem.GrammarInfo = GrammarInfo.Copy(); destItem.SemanticInfo = SemanticInfo.Copy(); destItem.IsWord = IsWord; destItem.PrepositionUsed = PrepositionUsed; destItem.EquivalentIds = new List<int>(EquivalentIds.Select(x => x).ToList()); destItem.EquivalentGUIDs = new List<string>(EquivalentGUIDs.Select(x => x).ToList()); destItem.Version = Version + 1; }
public void CopyFromSourceWord(SentenceElement sourceWord) { Id = sourceWord.Id; Position = sourceWord.Position; Order = sourceWord.Order; Text = sourceWord._text; SyntacticRole = sourceWord.SyntacticRole; IsRestored = sourceWord.IsRestored; SyntacticParentWordGUID = sourceWord.SyntacticParentWordGUID; SyntacticChain = sourceWord.SyntacticChain.DeepCopy(); UniformLinkChain = sourceWord.UniformLinkChain.DeepCopy(); SemanticInfo = sourceWord.SemanticInfo; ControllerNodes = sourceWord.ControllerNodes; ConjunctedWithGUID = sourceWord.ConjunctedWithGUID; GrammarInfo = sourceWord.GrammarInfo; EquivalentIds = sourceWord.EquivalentIds; EquivalentGUIDs = sourceWord.EquivalentGUIDs; }
public static SentenceElement Copy(SentenceElement item) { if (item == null) return null; var result = new SentenceElement { XML = item.XML, SyntacticChain = item.SyntacticChain.DeepCopy(), UniformLinkChain = item.UniformLinkChain.DeepCopy(), GUID = item.GUID, Id = item.Id, Position = item.Position, Order = item.Order, Text = item._text, ElementType = SentenceElementType.ReadFromString(item.ElementType.Value), Lemma = item.Lemma, SyntacticRole = SyntacticRole.ReadFromString(item.SyntacticRole.Value), SurfaceSlot = item.SurfaceSlot, IsRestored = item.IsRestored, SyntacticParentWordGUID = item.SyntacticParentWordGUID, SyntacticParentWordId = item.SyntacticParentWordId, ControllerNodes = item.ControllerNodes.ConvertAll( x => new Controller(x.ConnectionType.Value, x.OriginalText, x.OriginalWordGUID)), ConjunctedWithGUID = item.ConjunctedWithGUID, ConjunctedWithId = item.ConjunctedWithId, GrammarInfo = item.GrammarInfo.Copy(), SemanticInfo = item.SemanticInfo.Copy(), IsWord = item.IsWord, PrepositionUsed = item.PrepositionUsed, EquivalentIds = new List<int>(item.EquivalentIds.Select(x => x).ToList()), EquivalentGUIDs = new List<string>(item.EquivalentGUIDs.Select(x => x).ToList()), Version = item.Version + 1 }; return result; }
private void _addOrUpdateStandartUniformPart(SentenceElement uniformPart, string rowNr) { Debug.Assert(rowNr == UnknownRowNr); var uniformPartElement = All.Find(x => x.Id == uniformPart.Id); if (uniformPartElement != null) return; var uniformPartNewElement = new UniformPart(uniformPart, rowNr, -1, -1); Log.DebugFormat( $"[{Type}]Актуализация: Создание нового ОЧ: Id = {uniformPartNewElement.Id}, Текст = {uniformPartNewElement.Text}"); if (All.Any(x => x.RowNr == rowNr)) { Log.DebugFormat( $"[{Type}]Актуализация: Добавляем ОЧ с Id = {uniformPartNewElement.Id} в ряд с номером '{rowNr}'"); // добавляем его в объект того ряда, куда он входит, если таковых еще нет. if (All.Find(x => x.RowNr == uniformPartNewElement.RowNr && x.Id == uniformPartNewElement.Id) == null) { Items.ToList() .Find(x => x.Values.Select(y => y.RowNr).Contains(rowNr)) .Add(uniformPartNewElement.Order, uniformPartNewElement); } } else { var uniformPartsNewRow = new UniformPartRow {{uniformPartNewElement.Order, uniformPartNewElement}}; Log.DebugFormat($"[{Type}]Актуализация: Сформирован новый ряд ОЧ с номером '{rowNr}'"); // добавляем ряд к результатам Items.Add(uniformPartsNewRow); } }
private SentenceElement _addPredicate(Sentence sentence, int wordBeforeInsertOrder) { var predicate = new SentenceElement { SyntacticChain = NodeTree<string>.NewTree() , UniformLinkChain = NodeTree<string>.NewTree() , GUID = Guid.NewGuid().ToString() , Id = sentence.Elements.Last().Id + 1 , Position = wordBeforeInsertOrder + 1 , Order = wordBeforeInsertOrder + 1 , Text = "есть" , ElementType = SentenceElementType.Word , Lemma = "быть" , SyntacticRole = SyntacticRole.Predicate , SurfaceSlot = string.Empty , SyntacticParentWordId = -1 , SyntacticParentWordGUID = string.Empty , IsRestored = true , PrepositionUsed = PrepositionUsed.Undefined , ControllerNodes = new List<Controller>() , ConjunctedWithGUID = string.Empty , ConjunctedWithId = -1 , GrammarInfo = new GrammarInfo() { PartOfSpeech = PartOfSpeech.Verb , Case = Case.Undefined , IsSingular = false } , SemanticInfo = new SemanticInfo() , EquivalentGUIDs = new List<string>() , EquivalentIds = new List<int>() , IsWord = true }; sentence.AddWord(predicate); return predicate; }
public void AddInsert(Sentence sentence, RemovedTextElementInfo insert, List<int> insertsAreUps, SentenceElement upWordOutOfInsert, SentenceElement firstWord) { _items.Add(new Insert(sentence, insert, insertsAreUps, upWordOutOfInsert, firstWord)); }
private static bool _isConcordated(SentenceElement predicate, SentenceElement preliminaryPredicateElement) { return (predicate.GrammarInfo.Gender.Value == preliminaryPredicateElement.GrammarInfo.Gender.Value) && (predicate.GrammarInfo.IsSingular == preliminaryPredicateElement.GrammarInfo.IsSingular) && (predicate.GrammarInfo.Person.Value == preliminaryPredicateElement.GrammarInfo.Person.Value); }
public List<SentenceElement> SyntacticChildren(SentenceElement sourceElement) { return sourceElement == null ? null : Elements.FindAll(x => sourceElement.GUID == x.SyntacticParentWordGUID).ToList(); }
public void AddOrUpdateUniformPart(SentenceElement parent, SentenceElement child) { var obj = new QuasiUPAttachmentFinalResult { GUID = parent.GUID, ParentId = parent.Id, ChildId = child?.Id ?? -1, ParentText = parent.Text, ChildText = child?.Text ?? string.Empty }; if (_items.All(x => x.GUID != obj.GUID)) _items.Add(obj); }
private static bool _checkForArgeedWithSubject(SentenceElement subjectChild) { return (subjectChild.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Adjective.Value || subjectChild.GrammarInfo.PartOfSpeech.Value == PartOfSpeech.Participle.Value) && (subjectChild.SyntacticRole.Value == SyntacticRole.ConcordantAttr.Value || subjectChild.SyntacticRole.Value == SyntacticRole.AgreedAttribute.Value); }
public SentenceElement SyntacticParent(SentenceElement sourceElement) { return sourceElement == null ? null : Elements.Find(x => sourceElement.SyntacticParentWordGUID == x.GUID); }
private void _performPostProcessing(SubjectsPostProcessingHelperData hlpData, SentenceElement addedPredicate, SentenceElement adjectiveOrParticiple, SentenceElement subjectSentenceElement) { var oldSubjectSyntacticParent = subjectSentenceElement.SyntacticParentWordId; var oldAdjectiveOrParticipleSyntacticParent = adjectiveOrParticiple.SyntacticParentWordId; var oldAdjectiveOrParticipleSyntacticRole = adjectiveOrParticiple.SyntacticRole.Value; var oldAdjectiveOrParticipleSurfaceSlot = adjectiveOrParticiple.SurfaceSlot; subjectSentenceElement.SyntacticParentWordId = addedPredicate.Id; subjectSentenceElement.SyntacticParentWordGUID = addedPredicate.GUID; adjectiveOrParticiple.SyntacticParentWordId = addedPredicate.Id; adjectiveOrParticiple.SyntacticParentWordGUID = addedPredicate.GUID; adjectiveOrParticiple.SyntacticRole = SyntacticRole.Complement; adjectiveOrParticiple.SurfaceSlot = Consts.SurfaceSlotDefinedValues.ComplementAttributive; hlpData.AddOrUpdateCustomRow( adjectiveOrParticiple.GUID, oldAdjectiveOrParticipleSyntacticParent + "-->" + adjectiveOrParticiple.SyntacticParentWordId, oldAdjectiveOrParticipleSyntacticRole + "-->" + adjectiveOrParticiple.SyntacticRole.Value, oldAdjectiveOrParticipleSurfaceSlot + "-->" + adjectiveOrParticiple.SurfaceSlot ); hlpData.AddOrUpdateCustomRow( subjectSentenceElement.GUID, oldSubjectSyntacticParent + "-->" + subjectSentenceElement.SyntacticParentWordId, string.Empty, string.Empty ); }
private object[] _getLOPredicateInfo(List<PredicatePartHelperObject> loPredicate, Sentence sent, SentenceElement rootSentenceElement) { var allIds = string.Join(", ", loPredicate.ToList().Select(x => x.Id).ToList()); var auxLvl0 = string.Join(", ", loPredicate.FindAll(x => x.Level == 0 && x.PartType == PredicatePartType.AuxVerb).Select(x => x.Id)); var auxLvl1 = string.Join(", ", loPredicate.FindAll(x => x.Level == 1 && x.PartType == PredicatePartType.AuxVerb).Select(x => x.Id)); var auxLvl2 = string.Join(", ", loPredicate.FindAll(x => x.Level == 2 && x.PartType == PredicatePartType.AuxVerb).Select(x => x.Id)); var auxLvl3 = string.Join(", ", loPredicate.FindAll(x => x.Level == 3 && x.PartType == PredicatePartType.AuxVerb).Select(x => x.Id)); var infLvl1 = string.Join(", ", loPredicate.FindAll(x => x.Level == 1 && x.PartType == PredicatePartType.Infinitive).Select(x => x.Id)); var infLvl2 = string.Join(", ", loPredicate.FindAll(x => x.Level == 2 && x.PartType == PredicatePartType.Infinitive).Select(x => x.Id)); var infLvl3 = string.Join(", ", loPredicate.FindAll(x => x.Level == 3 && x.PartType == PredicatePartType.Infinitive).Select(x => x.Id)); return new object[] {allIds, auxLvl0, rootSentenceElement.Id, auxLvl1, infLvl1, auxLvl2, infLvl2, auxLvl3, infLvl3}; }
private SentenceElement _performSearchForConcordatedSubject(SentenceElement preliminaryPredicateElement, BaseSentenceAlgorithmData result, List<int> predicatesIds, List<SubjectFinalResult> subjects) { var checkPredicateOrders = new List<int>(); var predicateOrders = result.Sentence.Elements.FindAll(x => predicatesIds.Contains(x.Id)).Select(x => x.Order).ToList(); checkPredicateOrders.AddRange(predicateOrders.FindAll(x => x < preliminaryPredicateElement.Order).OrderByDescending(x => x).ToList()); checkPredicateOrders.AddRange(predicateOrders.FindAll(x => x > preliminaryPredicateElement.Order).OrderBy(x => x).ToList()); var checkPredicates = result.Sentence.Elements.FindAll(x => checkPredicateOrders.Contains(x.Order)); var x0PredicateChildrenSubjects = result.Sentence.SyntacticChildren(preliminaryPredicateElement).FindAll(x => subjects.Select(y => y.WordId).Contains(x.Id)).ToList(); Log.InfoFormat(" Нашли {0} подлежащих потомков у сказуемого Х0.", x0PredicateChildrenSubjects.Count()); Debug.Assert(x0PredicateChildrenSubjects.Count == 0); foreach (var predicate in checkPredicates) { Log.InfoFormat($" Проверяем сказуемое Id = {predicate.Id}, Text = {predicate.Text}, Order = {predicate.Order}, Order Сказуемого X0 = {preliminaryPredicateElement.Order}"); if (_isConcordated(predicate, preliminaryPredicateElement)) { Log.InfoFormat($" Проверямое сказуемое согласовано с Х0"); var predicateChildrenSubjects = result.Sentence.SyntacticChildren(predicate).FindAll(x => subjects.Select(y => y.WordId).Contains(x.Id)).ToList(); if (predicateChildrenSubjects.Any()) return predicateChildrenSubjects.First(); } } return null; }
private List<KeyValuePair<string, string>> _listProps(SentenceElement el) { return new List<KeyValuePair<string, string>> { new KeyValuePair<string, string>("Id:", el.Id.ToString()), new KeyValuePair<string, string>("Order:", el.Order.ToString()), new KeyValuePair<string, string>("Type:", el.ElementType.Value), new KeyValuePair<string, string>("Text:", el.Text), new KeyValuePair<string, string>("Lemma:", el.Lemma), new KeyValuePair<string, string>("Synt Role:", el.SyntacticRole.Value), new KeyValuePair<string, string>("Surface Slot:", el.SurfaceSlot), new KeyValuePair<string, string>("Is Restored:", el.IsRestored.ToString()), new KeyValuePair<string, string>("Synt Parent:", el.SyntacticParentWordId.ToString() + " :: " + (el.SyntacticParentWordId > 0 ? CurrentAlgSentenceElements.Find(x => x.Id == el.SyntacticParentWordId)?.Text: "--")), new KeyValuePair<string, string>("Conj. Id:", el.ConjunctedWithId.ToString() + " :: " + (el.ConjunctedWithId > 0 ? CurrentAlgSentenceElements.Find(x => x.Id == el.ConjunctedWithId)?.Text: "--")), new KeyValuePair<string, string>("Controller -->", el.ControllerNodes.Count > 0 ? "+" : "--"), new KeyValuePair<string, string>(" Type:", el.ControllerNodes.Count > 0 ? el.ControllerNodes[0].ConnectionType.Value : "--" ), new KeyValuePair<string, string>(" Orig Text:", el.ControllerNodes.Count > 0 ? el.ControllerNodes[0].OriginalText : "--" ), new KeyValuePair<string, string>("GrammarInfo -->", string.Empty), new KeyValuePair<string, string>(" Case:", el.GrammarInfo?.Case.Value), new KeyValuePair<string, string>(" PartOfSpeech:", el.GrammarInfo?.PartOfSpeech.Value), new KeyValuePair<string, string>(" IsSingular:", el.GrammarInfo?.IsSingular.ToString()), new KeyValuePair<string, string>(" ConjunctionType:", el.GrammarInfo?.ConjunctionType.Value), new KeyValuePair<string, string>(" Gender:", el.GrammarInfo?.Gender.Value), new KeyValuePair<string, string>(" Person:", el.GrammarInfo?.Person.Value), new KeyValuePair<string, string>("Semantic Info -->", string.Empty), new KeyValuePair<string, string>(" CommonClass:", el.SemanticInfo?.CommonClass.Value), new KeyValuePair<string, string>(" LexicalClass:", el.SemanticInfo?.LexicalClass.Value), new KeyValuePair<string, string>("Equivalents:", string.Join(",",el.EquivalentIds)), new KeyValuePair<string, string>("Version:", el.Version.ToString()) }; }