protected override bool IsParentMatchCondition(SubsentTuple tuple)
        {
            return(inderectspeech2.IsConditionPrecede(tuple.CHILD) &&
                   inderectspeech2.IsCondition(tuple.CHILD));

            //return (inderectspeech2.IsCondition( tuple.PARENT ));
        }
Exemplo n.º 2
0
        protected override bool IsSubsent2MatchCondition(SubsentTuple tuple, Language language, out IEnumerable <SubjectData> subjectData)
        {
            subjectData = null;

            var subsent    = tuple.SUBSENT2;
            var resultList = default(List <SubjectData>);
            var sd         = default(SubjectData);

            sd = pattern1.GetSubjectData(subsent, language);                    if (sd.IsNotNull())
            {
                goto NEXT;
            }
            sd = pattern2.GetSubjectData(subsent, language);                    if (sd.IsNotNull())
            {
                goto NEXT;
            }
            sd = pattern3_pointview.Instance.GetSubjectData(subsent); if (sd.IsNotNull())
            {
                goto NEXT;
            }
            sd = pattern4_opinion.Instance.GetSubjectData(subsent, language); if (sd.IsNotNull())
            {
                goto NEXT;
            }
            sd = pattern5_onglance.Instance.GetSubjectData(subsent); if (sd.IsNotNull())
            {
                goto NEXT;
            }
            sd = pattern23.GetSubjectData(subsent, language);                   if (sd.IsNotNull())
            {
                goto NEXT;
            }
            sd = pattern24.GetSubjectData(subsent, language);                   if (sd.IsNotNull())
            {
                goto NEXT;
            }

NEXT:
            sd.Add2List(ref resultList);

            if (resultList.AnyEx())
            {
                resultList = resultList.MakeDistinct();

                subjectData = resultList;
                return(true);
            }

            return(false);
        }
        protected override bool IsSubsent2MatchCondition(SubsentTuple tuple, Language language, out IEnumerable <SubjectData> subjectData)
        {
            subjectData = null;

            var resultList = default(List <SubjectData>);
            var subsent    = tuple.SUBSENT2;

            var subjectData1  = pattern12.GetSubjectData(subsent, language);
            var subjectData2  = pattern13.GetSubjectData(subsent, language);
            var subjectData3  = pattern15.GetSubjectData(subsent, language);
            var subjectData4  = pattern16.GetSubjectData(subsent, language);
            var subjectData5  = pattern17.GetSubjectData(subsent, language);
            var subjectData6  = pattern6.GetSubjectData(subsent, language);
            var subjectData7  = pattern18.GetSubjectData(subsent, language);
            var subjectData8  = pattern19.GetSubjectData(subsent, language);
            var subjectData9  = pattern20.GetSubjectData(subsent, language);
            var subjectData10 = pattern21.GetSubjectData(subsent, language);
            var subjectData11 = pattern22.GetSubjectData(subsent, language);
            var subjectData12 = pattern23.GetSubjectData(subsent, language);
            var subjectData13 = pattern24.GetSubjectData(subsent, language);

            subjectData1.Add2List(ref resultList);
            subjectData2.Add2List(ref resultList);
            subjectData3.Add2List(ref resultList);
            subjectData4.Add2List(ref resultList);
            subjectData5.Add2List(ref resultList);
            subjectData6.Add2List(ref resultList);
            subjectData7.Add2List(ref resultList);
            subjectData8.Add2List(ref resultList);
            subjectData9.Add2List(ref resultList);
            subjectData10.Add2List(ref resultList);
            subjectData11.Add2List(ref resultList);
            subjectData12.Add2List(ref resultList);
            subjectData13.Add2List(ref resultList);

            if (resultList.AnyEx())
            {
                resultList = resultList.MakeDistinct();

                subjectData = resultList;
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
        protected override bool IsParentMatchCondition(SubsentTuple tuple, Language language, out IEnumerable <SubjectData> subjectData)
        {
            subjectData = null;

            if (tuple.CHILD_DP.IsSubsentHasSubject())
            {
                return(false);
            }
            var verb = GetVerb(tuple.CHILD_DP.ElementsVerb(), language);

            if (verb.IsNull())
            {
                return(false);
            }

            var elements = tuple.CHILD_DP.ElementsBeforeSelf();

            if (elements.IsHasSubject())
            {
                return(false);
            }
            var subjects = GetSubjects(elements);

            if (!subjects.AnyEx())
            {
                return(false);
            }


            var subjectEssences = new List <SubjectEssence>();

            foreach (var s in subjects)
            {
                subjectEssences.Add(new SubjectEssence(s, verb));
            }

            var sd = new SubjectData(subjectEssences, subjects.First().Entity, verb);

            subjectData = sd.RepeatOnce();
            return(true);
        }
        protected override bool IsChildMatchCondition(SubsentTuple tuple, Language language, out IEnumerable <SubjectData> subjectData)
        {
            subjectData = null;

            var subsent    = tuple.CHILD;
            var resultList = default(List <SubjectData>);

            var sd = pattern1.GetSubjectData(subsent, language);

            sd.Add2List(ref resultList);

            if (resultList.AnyEx())
            {
                resultList = resultList.MakeDistinct();

                subjectData = resultList;
                return(true);
            }

            return(false);
        }
        public virtual SubjectObjectsTuple Process(SubsentTuple tuple, Language language
                                                   , ref int directAndIndirectSpeechGlobalNumber, ObjectAllocateMethod objectAllocateMethod)
        {
            #region [.condition.]
            var subjects = default(IEnumerable <SubjectData>);
            if (!IsSubsent2MatchCondition(tuple, language, out subjects))
            {
                return(null);
            }
            #endregion

            #region [.match condition.]
            MatchActionDebugInfoOutput(this.Id);

            //growup global IndirectSpeech-subsent number
            directAndIndirectSpeechGlobalNumber++;

            //set 'ISSUBJECT' attribute for subject-entity
            subjects.SetAttributeISSUBJECTforAllEntity(directAndIndirectSpeechGlobalNumber);

            //set 'ISOBJECT' attribute for all object-entity
            var id = subjects.GetAttributeIDForce();
            //allocate objects
            var objects = tuple.SUBSENT1.ElementsExceptT().TryAllocateObjectsInUnknownElements(objectAllocateMethod, id)
                          .Concat
                          (
                tuple.SUBSENT3.ElementsExceptT().TryAllocateObjectsInUnknownElements(objectAllocateMethod, id)
                          )
                          .ToArray();

            //mark begin-end DirectSpeech-subsents
            tuple.SUBSENT1.Elements().SetAttributeDIRECTSPEECH_BEGINEND(directAndIndirectSpeechGlobalNumber);
            tuple.SUBSENT3.Elements().SetAttributeDIRECTSPEECH_BEGINEND(directAndIndirectSpeechGlobalNumber);

            //add 2 result
            return(new SubjectObjectsTuple(subjects, objects, Id));

            #endregion
        }
Exemplo n.º 7
0
        public virtual SubjectObjectsTuple Process(SubsentTuple tuple, Language language
                                                   , ref int directAndIndirectSpeechGlobalNumber, ObjectAllocateMethod objectAllocateMethod)
        {
            #region [.condition.]
            var subjects = default(IEnumerable <SubjectData>);
            if (!IsParentMatchCondition(tuple, language, out subjects) ||
                !IsChildMatchCondition(tuple, language))
            {
                return(null);
            }
            #endregion

            #region [.match condition.]
            MatchActionDebugInfoOutput(this.Id);

            //growup global IndirectSpeech-subsent number
            directAndIndirectSpeechGlobalNumber++;

            //set 'ISSUBJECT' attribute for subject-entity
            subjects.SetAttributeISSUBJECTforAllEntity(directAndIndirectSpeechGlobalNumber);

            //set 'ISOBJECT' attribute for all object-entity
            var id = subjects.GetAttributeIDForce();

            //allocate objects
            var subsents = tuple.CHILD.AfterAndSelfSubsents().ToArray();
            var objects  = subsents.TryAllocateObjectsInSubsents(objectAllocateMethod, id).ToArray();

            //mark begin-end IndirectSpeech-subsents
            subsents.SetAttributeINDIRECTSPEECH_BEGINEND_4Subsents(directAndIndirectSpeechGlobalNumber);

            //add 2 result
            return(new SubjectObjectsTuple(subjects, objects, Id));

            #endregion
        }
        public virtual SubjectObjectsTuple Process(SubsentTuple tuple, Language language, int directAndIndirectSpeechGlobalNumber
                                                   , ObjectAllocateMethod objectAllocateMethod, SubjectObjectsTuple DSsubjectObjectsTuple)
        {
            #region [.condition.]
            var subjects = default(IEnumerable <SubjectData>);
            if (!IsParentMatchCondition(tuple, language, out subjects) ||
                !IsChildMatchCondition(tuple, language))
            {
                return(null);
            }
            #endregion

            //проверяем, что субъект высказывания Entity из DS остался тот же
            var e1 = from s1 in DSsubjectObjectsTuple.Subjects
                     from s2 in s1.SubjectEssences
                     select s2.Entity;
            var e2 = from s1 in subjects
                     from s2 in s1.SubjectEssences
                     select s2.Entity;
            if (e2.Except(e1).Any())
            {
                return(null);
            }

            #region [.match condition.]
            MatchActionDebugInfoOutput(this.Id);

            //set 'ISSUBJECT' attribute for subject-entity
            subjects.SetAttributeISSUBJECTforAllEntity(directAndIndirectSpeechGlobalNumber);

            //set 'ISOBJECT' attribute for all object-entity
            var id = subjects.GetAttributeIDForce();

            //allocate objects
            var subsents = tuple.CHILD.AfterAndSelfSubsents().ToArray();
            var objects  = subsents.TryAllocateObjectsInSubsents(objectAllocateMethod, id).ToArray();

            //mark begin-end IndirectSpeech-subsents
            subsents.SetAttributeINDIRECTSPEECH_BEGINEND_4Subsents(directAndIndirectSpeechGlobalNumber);

            //add 2 result
            var v1 = from s1 in DSsubjectObjectsTuple.Subjects
                     from s2 in s1.SubjectEssences
                     select s2.VerbValue;
            var v2 = from s1 in subjects
                     from s2 in s1.SubjectEssences
                     select s2.VerbValue;
            //склеиваем название нескольких (к.п. 2-х) глаголов
            var verbsValues = v1.Concat(v2).Distinct().JoinBy(", ");

            //создем новые пары субъект высказывания Entity - название нескольких (к.п. 2-х) глаголов Verb
            var se = from s1 in DSsubjectObjectsTuple.Subjects
                     from s2 in s1.SubjectEssences
                     select new SubjectEssence(s2, verbsValues);

            //создем новый IEnumerable< SubjectData >
            subjects = new SubjectData
                       (
                se.ToList(),
                DSsubjectObjectsTuple.Subjects.First().LeftExtremeElement,
                subjects.Last().RightExtremeElement
                       )
                       .RepeatOnce();
            //создаем объединенный результат some-rule-DS + IS_ParentChild_DanglingParticipleAfterDS_01
            return(new SubjectObjectsTuple(subjects,
                                           DSsubjectObjectsTuple.Objects.Select(o => o.Entity).Concat(objects),
                                           DSsubjectObjectsTuple.RuleId + " + " + Id));

            #endregion
        }
 protected abstract bool IsChildMatchCondition(SubsentTuple tuple, Language language);
 protected abstract bool IsParentMatchCondition(SubsentTuple tuple, Language language, out IEnumerable <SubjectData> subjectData);
 protected override bool IsChildMatchCondition(SubsentTuple tuple, Language language)
 {
     return(inderectspeech3.IsCondition(tuple.CHILD, language));
 }
Exemplo n.º 12
0
        public virtual SubjectObjectsTuple Process(SubsentTuple tuple, Language language
                                                   , ref int directAndIndirectSpeechGlobalNumber, ObjectAllocateMethod objectAllocateMethod)
        {
            #region [.condition.]
            var subjects = default(IEnumerable <SubjectData>);
            if (!IsSubsent2MatchCondition(tuple, language, out subjects))
            {
                return(null);
            }
            #endregion

            #region [.match condition.]
            //allocate objects
            var subsents1 = tuple.SUBSENT1.BeforeSubsents().ToArray();
            if (subjects.HasAnySubjectEntityAncestorInAnySubsents(subsents1))
            {
                return(null);
            }

            var subsents3 = tuple.SUBSENT3.AfterAndSelfSubsents().ToArray();
            if (subjects.HasAnySubjectEntityAncestorInAnySubsents(subsents3))
            {
                return(null);
            }

            MatchActionDebugInfoOutput(this.Id);

            //growup global IndirectSpeech-subsent number
            directAndIndirectSpeechGlobalNumber++;

            //set 'ISSUBJECT' attribute for subject-entity
            subjects.SetAttributeISSUBJECTforAllEntity(directAndIndirectSpeechGlobalNumber);

            //set 'ISOBJECT' attribute for all object-entity
            var id = subjects.GetAttributeIDForce();

            var objects1 = subsents1.TryAllocateObjectsInSubsents(objectAllocateMethod, id).ToArray();
            //mark begin-end IndirectSpeech-subsents-1
            subsents1.SetAttributeINDIRECTSPEECH_BEGINEND_4Subsents(directAndIndirectSpeechGlobalNumber);

            var objects3 = subsents3.TryAllocateObjectsInSubsents(objectAllocateMethod, id).ToArray();
            //mark begin-end IndirectSpeech-subsents-3
            subsents3.SetAttributeINDIRECTSPEECH_BEGINEND_4Subsents(directAndIndirectSpeechGlobalNumber);

            var u                = tuple.SUBSENT1.ElementsExceptT().LastOrDefault();
            var elements1        = tuple.SUBSENT1.Elements().TakeWhile(e => e != u);
            var elements1objects = elements1.TryAllocateObjects(objectAllocateMethod, id).ToArray();
            //mark begin-end IndirectSpeech-subsents-1
            elements1.SetAttributeINDIRECTSPEECH_BEGINEND(directAndIndirectSpeechGlobalNumber);

            //build all objects
            var objects = objects1
                          .Concat
                          (
                elements1objects
                          )
                          .Concat
                          (
                objects3
                          )
                          .ToArray();

            //add 2 result
            return(new SubjectObjectsTuple(subjects, objects, Id));

            #endregion
        }
Exemplo n.º 13
0
 protected override bool IsSubsent1MatchCondition(SubsentTuple tuple, Language language)
 {
     return(inderectspeech2.IsCondition(tuple.SUBSENT1));
 }
        public virtual SubjectObjectsTuple Process(SubsentTuple tuple, Language language
                                                   , ref int directAndIndirectSpeechGlobalNumber, ObjectAllocateMethod objectAllocateMethod)
        {
            #region [.condition.]
            var subjects = default(IEnumerable <SubjectData>);
            if (!IsParentMatchCondition(tuple) ||
                !IsChildMatchCondition(tuple, language, out subjects))
            {
                return(null);
            }
            #endregion

            #region [.match condition.]
            MatchActionDebugInfoOutput(this.Id);

            //growup global IndirectSpeech-subsent number
            directAndIndirectSpeechGlobalNumber++;

            //set 'ISSUBJECT' attribute for subject-entity
            subjects.SetAttributeISSUBJECTforAllEntity(directAndIndirectSpeechGlobalNumber);

            //set 'ISOBJECT' attribute for all object-entity
            var id = subjects.GetAttributeIDForce();
            #region previous. commented

            /*
             * //allocate objects
             * var objects = tuple.PARENT.ElementsExceptT().TryAllocateObjects( id )
             *           .Concat
             *           (
             *           tuple.SUBSENT3.ElementsExceptT().TryAllocateObjects( id )
             *           );
             *
             * //create IndirectSpeech-parent-1
             * var subsentIS = directAndIndirectSpeechGlobalNumber.CreateSubsentIndirectSpeech();
             * subsentIS.MoveIn2ThisAllNodes( tuple.PARENT.Nodes().TakeWhile( n => n != tuple.CHILD ) );
             * tuple.CHILD.AddBeforeSelf( subsentIS );
             *
             * //create IndirectSpeech-subsent-3
             * subsentIS = directAndIndirectSpeechGlobalNumber.CreateSubsentIndirectSpeech();
             * subsentIS.MoveIn2ThisAllNodes( tuple.SUBSENT3.Nodes() );
             * tuple.SUBSENT3.Add( subsentIS );
             */
            #endregion

            //allocate objects
            var elements1 = tuple.PARENT.Elements().TakeWhile(e => e != tuple.CHILD);

            var subsents1 = tuple.PARENT.BeforeSubsents().ToArray();
            var subsents3 = tuple.SUBSENT3.AfterAndSelfSubsents().ToArray();

            var objects = subsents1.TryAllocateObjectsInSubsents(objectAllocateMethod, id)
                          .Concat
                          (
                elements1.TryAllocateObjects(objectAllocateMethod, id)
                          )
                          .Concat
                          (
                subsents3.TryAllocateObjectsInSubsents(objectAllocateMethod, id)
                          )
                          .ToArray();

            //mark begin-end IndirectSpeech-subsents-1
            subsents1.SetAttributeINDIRECTSPEECH_BEGINEND_4Subsents(directAndIndirectSpeechGlobalNumber);
            elements1.SetAttributeINDIRECTSPEECH_BEGINEND(directAndIndirectSpeechGlobalNumber);

            //mark begin-end IndirectSpeech-subsents-3
            subsents3.SetAttributeINDIRECTSPEECH_BEGINEND_4Subsents(directAndIndirectSpeechGlobalNumber);

            //add 2 result
            return(new SubjectObjectsTuple(subjects, objects, Id));

            #endregion
        }
 protected abstract bool IsParentMatchCondition(SubsentTuple tuple);