Exemple #1
0
        private ITerm TryGetPredicate()
        {
            ITerm result = null;

            var verb = AdTree.GetRightSequence().FirstOrDefault(x => AttributesModel.IsVerb(x.Morpheme.Attributes));

            if (verb != null)
            {
                IAdTree predicateAdTree;

                var verbValencies = AttributesModel.GetNumberOfValencies(verb.Morpheme.Attributes);
                if (verbValencies > 0)
                {
                    predicateAdTree = verb.GetSequenceToRoot()
                                      .First(x => x.AdPosition == null || AttributesModel.IsU(x.AdPosition.Morpheme.Attributes))
                                      .MakeDeepCopy();

                    // Remove the subject (i.e. remove the sub-adtree on the first valency)
                    var firstValency = predicateAdTree.GetRightSequence().FirstOrDefault(x => x.Pattern.ValencyPosition == 1);
                    if (firstValency != null)
                    {
                        firstValency.Left = null;
                    }
                }
                else
                {
                    predicateAdTree = verb.MakeDeepCopy();
                    result          = Factory.CreateTerm(verb, StructureAttributes.Term.Predicate);
                }

                result = Factory.CreateTerm(predicateAdTree, StructureAttributes.Term.Predicate);
            }

            return(result);
        }
Exemple #2
0
        private ITerm TryGetSubject()
        {
            ITerm result = null;

            var verb = AdTree.RightChildren?.FirstOrDefault(x => AttributesModel.IsVerb(x.Morpheme.Attributes));

            if (verb != null)
            {
                var valencies = AttributesModel.GetNumberOfValencies(verb.Morpheme.Attributes);
                if (valencies >= 1)
                {
                    var valency1 = verb.GetSequenceToRoot().FirstOrDefault(x => x.Pattern.ValencyPosition == 1);
                    if (valency1?.Left != null)
                    {
                        var subjectAdTree = valency1.Left.MakeDeepCopy();
                        result = Factory.CreateTerm(subjectAdTree, StructureAttributes.Term.Subject);
                    }
                }
            }

            return(result);
        }