protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSyntacticParent(Name,
         HelperDataFindFalseConjunctionSParetnForSId.Name
         , HelperDataFindFalseConjunctionSNewGrandParentId.Name
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeTextValue(Name,
         HelperDataFalseDirectObjectReconstructionSubstantivatorControllerId.Name
         , HelperDataFalseDirectObjectReconstructionSubstantivatorControllerText.Name
         , sourceSentence, data);
 }
Example #3
0
        public static List<PostPropcessingActionInfo> ChangePartOfSpeech(string actionName, string columnName, string newPartOfSpeechValue, Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<KeyValuePair<int, string>>();

            foreach (DataRow row in data.Rows)
            {
                var sourceId = row.Field<int>(columnName);

                if (sourceId > 0)
                    words.Add(new KeyValuePair<int, string>(sourceId, newPartOfSpeechValue));
            }

            foreach (var pair in words)
            {
                var wordId = pair.Key;
                var newPartOfSpeech = pair.Value;
                var modifiedWord = sourceSentence.Elements.Find(x => x.Id == wordId);
                var oldModWordPartOfSpeech = modifiedWord.GrammarInfo.PartOfSpeech.Value;

                modifiedWord.GrammarInfo.PartOfSpeech = PartOfSpeech.ReadFromString(newPartOfSpeech);

                result.Add(new PostPropcessingActionInfo(actionName, wordId, nameof(modifiedWord.GrammarInfo.PartOfSpeech), oldModWordPartOfSpeech, modifiedWord.GrammarInfo.PartOfSpeech.Value));
            }

            return result;
        }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangePartOfSpeech(Name,
         HelperDataFindFalseParticleIIds.Name
         , PartOfSpeech.Conjunction.Value
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSyntacticParent(Name,
         HelperDataConjunctedWordsForPSSWordId.Name
         , HelperDataConjunctedWordsForPSSConjunctedId.Name
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangePartOfSpeech(Name,
         HelperDataColumnElementId.Name
         , PartOfSpeech.Preposition.Value
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSyntacticParent(Name,
         HelperDataUPAdjectiveForElliptedNounPESTrue.Name
         , HelperDataUPAdjectiveForElliptedNounSSPES.Name
         , sourceSentence, data);
 }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var wordPairs = new Dictionary<int, int>();

            var firstGroupingColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ConfirmedNr.Name;
            var secondGroupingColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ParentNr.Name;
            var sourceColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ParentId.Name;
            var destColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ConfirmedId.Name;

            foreach (DataRow row in data.Rows)
            {
                if (row.Field<int>(firstGroupingColumnName) > -1)
                    row.SetField(secondGroupingColumnName, row.Field<int>(firstGroupingColumnName));
                if (row.Field<int>(secondGroupingColumnName) > -1)
                    row.SetField(firstGroupingColumnName, row.Field<int>(secondGroupingColumnName));
            }

            foreach (var group in data.AsEnumerable().GroupBy(grp => grp.Field<int>(firstGroupingColumnName)))
            {
                var parentColValues = group.ToList().Find(x => x.Field<int>(sourceColumnName) > -1);
                var childColValues = group.ToList().Find(x => x.Field<int>(destColumnName) > -1);
                var parentId = parentColValues?.Field<int>(sourceColumnName) ?? -1;
                var childId = childColValues?.Field<int>(destColumnName) ?? -1;

                if (parentId > 0 && childId > 0)
                {
                    wordPairs.Add(parentId, childId);
                }
            }

            PostProcessingUtils.AddConjunctionLink(Name, wordPairs, sourceSentence, result);

            return result;
        }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSyntacticParent(Name
         , HelperDataElliptedNounLinkFeatureCoordinatingConjunctionId.Name
         , HelperDataElliptedNounLinkFeatureSSPESId.Name
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSurfaceSlotToKnownValue(Name,
         HelperDataThenConjunctionId.Name
         , Consts.SurfaceSlotDefinedValues.CorrelateCondTemp
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSurfaceSlotToKnownValue(Name,
         HelperDataIfConjunctionParetntId.Name
         , Consts.SurfaceSlotDefinedValues.AdjunctConditionClause
         , sourceSentence, data);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSyntacticParent(Name
         , HelperDataConcordanceResultlSPSSId.Name
         , HelperDataLostConjunctionLinkConjunctedWithSPSSParentId.Name
         , sourceSentence, data);
 }
Example #13
0
 public void Process(Sentence sourceSentence, BaseHelperData data)
 {
     Results = DoProcess(sourceSentence, data);
     if (Results.Count > 0)
         Log.InfoFormat("Выполнены действия по модификации лога:{0}{1}", Environment.NewLine, _dumpPostProcessingResults(Results));
     else
         Log.InfoFormat("Действий по модификации лога не было выполнено. [{0}] ", Name);
 }
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.ChangeSurfaceSlot(Name,
         HelperDataQuasiUniformPartsAttachmentMainType2ConfirmedId.Name
         , HelperDataQuasiUniformPartsAttachmentMainType2ParentId.Name
         , HelperDataQuasiUniformPartsAttachmentMainType2ConfirmedNr.Name
         , HelperDataQuasiUniformPartsAttachmentMainType2ParentNr.Name
         , sourceSentence, data);
 }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var predicateValues = data.ColumnIntPositiveValues(HelperDataNearestPredicateAfterThenPredicateId.Name);
            var predicateValue = -1;
            if (predicateValues.Any())
                predicateValue = predicateValues.First();

            return PostProcessingUtils.ChangeSyntacticParentForKnownValue(Name,
                    HelperDataIfConjunctionParetntId.Name,
                    predicateValue
                    , sourceSentence, data);
        }
Example #16
0
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();

            var wordPairs = new Dictionary<int, int>();

            // добавляем сочинительную связь между ССПСС и ПСС
            foreach (DataRow row in data.Rows)
                if (row.Field<int>(HelperDataConjunctedWordsForPSSConjunctedId.Name) > 0)
                wordPairs.Add(row.Field<int>(HelperDataConjunctedWordsForPSSConjunctedId.Name), row.Field<int>(HelperDataConjunctedWordsForPSSWordId.Name));

            PostProcessingUtils.AddConjunctionLink(Name, wordPairs, sourceSentence, result);

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<int>();

            foreach (DataRow row in data.Rows)
            {
                var suspectedId = row.Field<int>(HelperDataBetweenAndISuspectedId.Name);
                if (suspectedId > 0)
                    words.Add(suspectedId);
            }

            PostProcessingUtils.DeleteConjunctionLink(Name, words, sourceSentence, result);

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<KeyValuePair<int, string>>();

            foreach (DataRow row in data.Rows)
            {
                var parentForS = row.Field<int>(HelperDataFindFalseConjunctionSParetnForSId.Name);
                if (parentForS > 0)
                    words.Add(new KeyValuePair<int, string>(parentForS, SyntacticRole.IndirectObject.Value));
            }

            PostProcessingUtils.ChangeSyntacticRole(Name, words, sourceSentence, result);

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<int>();

            foreach (DataRow row in data.Rows)
            {
                var sspWordId = row.Field<int>(HelperDataFindElliptedNounIntermedaiteFalseUpId.Name);
                if (sspWordId > 0)
                    words.Add(sspWordId);
            }

            PostProcessingUtils.DeleteConjunctionLink(Name, words, sourceSentence, result);

            return result;
        }
Example #20
0
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var wordPairs = new Dictionary<int, int>();

            foreach (DataRow row in data.Rows)
            {
                var pesId = row.Field<int>(HelperDataUPAdjectiveForElliptedNounPESTrue.Name);
                var sspesId = row.Field<int>(HelperDataUPAdjectiveForElliptedNounSSPES.Name);

                if (pesId > -1 && sspesId > -1)
                    wordPairs.Add(pesId, sspesId);
            }

            // добавляем сочинительную связь между ССПСС и ПСС
            PostProcessingUtils.AddConjunctionLink(Name, wordPairs, sourceSentence, result);

            return result;
        }
Example #21
0
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var wordPairs = new Dictionary<int, int>();
            foreach (DataRow row in data.Rows)
            {
                var parentId = row.Field<int>(HelperDataLostConjunctionLinkConjunctedWithSPSSId.Name);
                var childId = row.Field<int>(HelperDataConcordanceResultlSPSSId.Name);
                if (parentId > 0 && childId > 0)
                {
                    wordPairs.Add(parentId, childId);
                }

            }

            PostProcessingUtils.AddConjunctionLink(Name, wordPairs, sourceSentence, result);

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<int>();

            foreach (DataRow row in data.Rows)
            {
                var sspWordId = row.Field<int>(HelperDataSubjectAndPredicateConjunctionSubjectIdSSP.Name);
                if (sspWordId > 0)
                    words.Add(sspWordId);

                var pssWordId = row.Field<int>(HelperDataSubjectAndPredicateConjunctionPredicateIdPSS.Name);
                if (pssWordId > 0)
                    words.Add(pssWordId);
            }

            PostProcessingUtils.DeleteConjunctionLink(Name, words, sourceSentence, result);

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();

            var wordPairsgroups =
                data.Rows.Cast<DataRow>().GroupBy(grp => grp.Field<int>(HelperDataParticleISourceId.Name));

            var wordPairs = new Dictionary<int, int>();
            foreach (var group in wordPairsgroups)
            {
                wordPairs.Add(
                    group.Select(x => x.Field<int>(HelperDataParticleIParentConjuctedWordId.Name)).First(x => x > -1),
                    group.Select(x => x.Field<int>(HelperDataParticleIParentWordId.Name)).First(x => x > -1)
                    );
            }

            // добавляем сочинительную связь между родитилем И, и текстовым элементом, имеющим такую синт роль
            PostProcessingUtils.AddConjunctionLink(Name, wordPairs, sourceSentence, result);

            return result;
        }
Example #24
0
        public static List<PostPropcessingActionInfo> ChangeSurfaceSlot(string actionName, string sourceColumnName, string destColumnName, string groupColumnNameFirst, string groupColumnNameSecond, Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<KeyValuePair<int, int>>();

            foreach (DataRow row in data.Rows)
            {
                if(row.Field<int>(groupColumnNameFirst) > -1)
                    row.SetField(groupColumnNameSecond, row.Field<int>(groupColumnNameFirst));
                if (row.Field<int>(groupColumnNameSecond) > -1)
                    row.SetField(groupColumnNameFirst, row.Field<int>(groupColumnNameSecond));
            }

            foreach (var group in data.AsEnumerable().GroupBy(grp => grp.Field<int>(groupColumnNameFirst)))
            {
                var sourceColValues = group.ToList().Find(x => x.Field<int>(sourceColumnName) > -1);
                var destColValues = group.ToList().Find(x => x.Field<int>(destColumnName) > -1);
                var sourceId = sourceColValues?.Field<int>(sourceColumnName) ?? -1;
                var destId = destColValues?.Field<int>(destColumnName) ?? -1;

                if (sourceId > 0 && destId > 0)
                    words.Add(new KeyValuePair<int, int>(sourceId, destId));
            }

            foreach (var pair in words)
            {
                var wordId = pair.Key;
                var newSurfaceSlot = sourceSentence.Elements.Find(x => x.Id == pair.Value).SurfaceSlot;
                var modifiedWord = sourceSentence.Elements.Find(x => x.Id == wordId);
                var modWordSurfaceSlot = modifiedWord.SurfaceSlot;

                modifiedWord.SurfaceSlot = newSurfaceSlot;

                result.Add(new PostPropcessingActionInfo(actionName, wordId, nameof(modifiedWord.SurfaceSlot), modWordSurfaceSlot, modifiedWord.SurfaceSlot));
            }

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<KeyValuePair<int, string>>();

            foreach (DataRow row in data.Rows)
            {
                var pssId = row.Field<int>(HelperDataConjunctedWordsForPSSWordId.Name);
                var sspssId = row.Field<int>(HelperDataConjunctedWordsForPSSConjunctedId.Name);

                if (pssId > 0 && sspssId > 0)
                {
                    var sspss = sourceSentence.Elements.Find(x => x.Id == sspssId);
                    var newRoleValue = sspss.SyntacticRole.Value;
                    words.Add(new KeyValuePair<int, string>(pssId, newRoleValue));
                }

            }

            PostProcessingUtils.ChangeSyntacticRole(Name, words, sourceSentence, result);

            return result;
        }
        protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
        {
            var result = new List<PostPropcessingActionInfo>();
            var words = new List<KeyValuePair<int, string>>();
            var firstGroupingColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ConfirmedNr.Name;
            var secondGroupingColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ParentNr.Name;
            var sourceColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ConfirmedId.Name;
            var destColumnName = HelperDataQuasiUniformPartsAttachmentMainType2ParentId.Name;

            foreach (DataRow row in data.Rows)
            {
                if (row.Field<int>(firstGroupingColumnName) > -1)
                    row.SetField(secondGroupingColumnName, row.Field<int>(firstGroupingColumnName));
                if (row.Field<int>(secondGroupingColumnName) > -1)
                    row.SetField(firstGroupingColumnName, row.Field<int>(secondGroupingColumnName));
            }

            foreach (var group in data.AsEnumerable().GroupBy(grp => grp.Field<int>(firstGroupingColumnName)))
            {
                var sourceColValues = group.ToList().Find(x => x.Field<int>(sourceColumnName) > -1);
                var destColValues = group.ToList().Find(x => x.Field<int>(destColumnName) > -1);
                var sourceId = sourceColValues?.Field<int>(sourceColumnName) ?? -1;
                var destId = destColValues?.Field<int>(destColumnName) ?? -1;

                if (sourceId > 0 && destId > 0)
                {
                    var dest = sourceSentence.GetElement(destId);
                    var newRoleValue = dest.SyntacticRole.Value;
                    words.Add(new KeyValuePair<int, string>(sourceId, newRoleValue));
                }
            }

            PostProcessingUtils.ChangeSyntacticRole(Name, words, sourceSentence, result);

            return result;
        }
        private void _prepareDirectObject(BaseHelperData data, string idColumnName, string predicateIdColumnName, string predicateNrColumnName, DirectObjectType type, Sentence sentence)
        {
            foreach (var row in data.AsEnumerable().ToList().FindAll(x => x.Field<int>(idColumnName) > -1))
            {
                var sentenceElement = sentence.GetElement(row.Field<int>(idColumnName));
                var predicateId = row.Field<int>(predicateIdColumnName);
                var predicateNr = row.Field<string>(predicateNrColumnName);

                DirectObjects.Add(new DirectObject()
                {
                    Id = sentenceElement.Id,
                    GUID = sentenceElement.GUID,
                    Text = sentenceElement.Text,
                    ControlPredicateId = predicateId,
                    ControlPredicateNr = predicateNr,
                    Type = type
                });
            }
        }
Example #28
0
        private BaseHelperData _preprocessAlgResults(BaseHelperData algRes)
        {
            var result = new DisplayableHelperData
            {
                SortingData = algRes.SortingData,
                TableName = algRes.TableName,
                FrozenColumnCount = algRes.FrozenColumnCount
            };

            foreach (BaseHelperDataColumn resCol in algRes.Columns)
            {
                var hColor = resCol.HeaderColor;

                result.Columns.Add(new ResultViewColumn
                {
                    ColumnName = resCol.ColumnName,
                    Caption = resCol.Caption,
                    DataType = typeof(string),
                    CellColor = Color.FromArgb(hColor.A, hColor.R, hColor.G, hColor.B)
                });
            }

            foreach (DataRow resRow in algRes.Rows)
            {
                result.Rows.Add(resRow.ItemArray.Select(o =>
                {
                    var str = o.ToString();
                    var res = str != "-1" ? o : "-";
                    int strInt;
                    if (int.TryParse(str, out strInt) && strInt > 0 && strInt < 10)
                    {
                        res = "0" + strInt.ToString();
                    }
                    return res;
                }).ToArray());
            }

            return result;
        }
Example #29
0
 protected override List<PostPropcessingActionInfo> DoProcess(Sentence sourceSentence, BaseHelperData data)
 {
     return PostProcessingUtils.DeleteWordsForBetweenI(Name, sourceSentence, data);
 }
        public static void Process(BaseHelperData sourceData, BaseSentenceAlgorithmData result, string objectIdColumnName, string objectTypeColumnName, Sentence sentence,
            bool isSubjectProcessed = false, bool isDirectObjectProcessed = false)
        {
            Debug.Assert(isSubjectProcessed || isDirectObjectProcessed == true);

            foreach (DataRow row in sourceData.Rows)
            {
                var objectSentenceElement = sentence.GetElement(row.Field<int>(objectIdColumnName));
                var objectElementType = row.Field<string>(objectTypeColumnName);

                var objectSubstantivatorSubType = ObjectSubstantivatorType.Undefined;
                var controllerNode = objectSentenceElement.ControllerNodes.Find(x => x.ConnectionType.Value == ControllerConnectionType.Coreferential.Value);

                if (objectSentenceElement.SemanticInfo.LexicalClass.Value == SemanticInfoLexicalClass.SubstantivatorControlled.Value
                    && controllerNode != null)
                {
                    objectSubstantivatorSubType = ObjectSubstantivatorType.HasController;
                    var newText = controllerNode.OriginalText;
                    var newLemma = sentence.GetElement(controllerNode.OriginalWordGUID).Lemma;

                    // указаны массивы для Подлежащего
                    result.HelperData.AddOrUpdateCustomRow(objectSentenceElement.GUID,
                        objectSentenceElement.Id, //12
                        objectElementType, // --
                        objectSentenceElement.Id, //3.1
                        newText, //П100
                        newLemma, //П100.1
                        -1, //3.2
                        -1, //3.0
                        newText, //100
                        -1, // 6.1
                        objectSentenceElement.Id, //7
                        objectSubstantivatorSubType, //П101
                        sentence.GetElement(controllerNode.OriginalWordGUID).Order //7.1
                        );

                    if(isSubjectProcessed)
                        result.FinalResults.SubjectsFinalResults.AddOrUpdateSubject(objectSentenceElement, SubjectClass.Undefined, objectSubstantivatorSubType, aId: null, bId: objectSentenceElement.Id);
                }
                else if (objectSentenceElement.SemanticInfo.LexicalClass.Value == SemanticInfoLexicalClass.SubstantivatorInanimate.Value
                    || objectSentenceElement.SemanticInfo.LexicalClass.Value == SemanticInfoLexicalClass.SubstantivatorAnimate.Value)
                {
                    foreach (var child in result.Sentence.SyntacticChildren(objectSentenceElement.Id))
                    {
                        objectSubstantivatorSubType = ObjectSubstantivatorType.Definition;
                        result.HelperData.AddOrUpdateCustomRow(objectSentenceElement.GUID,
                            objectSentenceElement.Id,
                            objectElementType,
                            -1,
                            string.Empty,
                            string.Empty,
                            objectSentenceElement.Id,
                            -1,
                            string.Empty,
                            child.Id,
                            child.Id,
                            objectSubstantivatorSubType,
                            child.Order);
                        if (isSubjectProcessed)
                        {
                            result.FinalResults.SubjectsFinalResults.All.RemoveAll(x => x.AId == objectSentenceElement.Id);
                            result.FinalResults.SubjectsFinalResults.AddOrUpdateSubject(child, SubjectClass.Undefined,
                                objectSubstantivatorSubType, aId: null, bId: child.Id);
                        }
                    }
                }
                else
                {
                    objectSubstantivatorSubType = ObjectSubstantivatorType.NonSubstantivator;
                    result.HelperData.AddOrUpdateCustomRow(objectSentenceElement.GUID,
                        objectSentenceElement.Id,
                        objectElementType,
                        -1,
                        string.Empty,
                        string.Empty,
                        -1,
                        objectSentenceElement.Id,
                        string.Empty,
                        -1,
                        objectSentenceElement.Id,
                        objectSubstantivatorSubType,
                        objectSentenceElement.Order);

                    if(isSubjectProcessed)
                    result.FinalResults.SubjectsFinalResults.AddOrUpdateSubject(objectSentenceElement, SubjectClass.Undefined, objectSubstantivatorSubType, aId: null, bId: objectSentenceElement.Id);
                }
            }
        }