コード例 #1
0
ファイル: Verb.cs プロジェクト: lchaloupsky/Image-generator
        private IProcessable ProcessElement(Noun noun, ISentenceGraph graph)
        {
            // if noun is subject, process this
            if (this.DependencyHelper.IsSubject(noun.DependencyType))
            {
                if (this.DrawableAdposition != null)
                {
                    noun.Process(this.DrawableAdposition, graph);
                    this.DrawableAdposition = null;
                }

                return(noun.Process(this, graph));
            }

            // if noun is object, save it as part of this verb, else save it for future
            if (this.DependencyHelper.IsObject(noun.DependencyType) && this.Object == null)
            {
                this.Object = noun;
            }
            else
            {
                this.DependingDrawables.Add(noun);
            }

            return(this);
        }
コード例 #2
0
        private IProcessable ProcessElement(Noun noun, ISentenceGraph graph)
        {
            // Process merging coordination type
            if (this.DependencyHelper.IsConjuction(noun.DependencyType) && this.CoordinationTypeHelper.IsMergingCoordination(this.CoordinationType))
            {
                // Try to create edge between elements
                IPositionateEdge newEdge = this.EdgeFactory.Create(
                    this,
                    noun,
                    new List <string>(),
                    noun.Adpositions.SelectMany(a => a.GetAdpositions()).Select(a => a.ToString()).ToList(),
                    this.DependencyHelper.IsSubject(noun.DependencyType)
                    );

                if (newEdge != null)
                {
                    noun.Adpositions.Clear();
                    graph.AddEdge(newEdge);
                    noun.FinalizeProcessing(graph);
                    return(this);
                }

                // If no edge was found create new noun set
                return(this.ElementFactory.Create(this, noun, graph));
            }

            // Part of noun phrase
            if (this.DependencyHelper.IsCompound(noun.DependencyType) || this.DependencyHelper.IsNounPhrase(noun.DependencyType) || this.DependencyHelper.IsName(noun.DependencyType))
            {
                this.Extensions.Add(noun);
                graph.ReplaceVertex(this, noun);

                return(this);
            }

            // Skip possessive relation
            if (this.DependencyHelper.IsPossesive(noun.DependencyType))
            {
                return(this);
            }

            // Return depending drawable if this is negated
            if (this.IsNegated && this.DependencyHelper.IsObject(this.DependencyType))
            {
                return(noun);
            }

            // Processing relationship between noun set and this
            this.DrawableHelper.ProcessEdge(graph, this.EdgeFactory, this, noun, this.Adpositions, noun.Adpositions, this.DependencyHelper.IsSubject(noun.DependencyType), () =>
            {
                // Add to extensions
                this.Extensions.Add(noun);
            });

            // Finalize processed noun
            noun.FinalizeProcessing(graph);

            return(this);
        }
コード例 #3
0
 // Constructs noun set of noun plural form with default number of instances
 public NounSet(ElementFactory elementFactory, IEdgeFactory edgeFactory, Noun noun, string pluralForm) : this(elementFactory, edgeFactory)
 {
     this.Id             = noun.Id;
     this.DependencyType = noun.DependencyType;
     this.PluralForm     = pluralForm;
     this.BaseNoun       = noun;
     this.Nouns.Add(noun);
 }
コード例 #4
0
        private IProcessable ProcessElement(Noun noun, ISentenceGraph graph)
        {
            if (this.DependencyHelper.IsCompound(noun.DependencyType) || this.DependencyHelper.IsNominalPossesive(noun.DependencyType))
            {
                noun.DependencyType = this.DependencyType;
            }

            return(noun.Process(this, graph));
        }
コード例 #5
0
 // Constructs noun set with given noun and given number of instances
 public NounSet(ElementFactory elementFactory, IEdgeFactory edgeFactory, Noun noun, int numberOfInstances) : this(elementFactory, edgeFactory)
 {
     this.Id             = noun.Id;
     this.DependencyType = noun.DependencyType;
     this.Nouns.Add(noun);
     this.GenerateNouns(numberOfInstances);
     this.NumberOfInstances = numberOfInstances;
     this.PluralForm        = noun.Lemma;
     this.BaseNoun          = noun;
 }
コード例 #6
0
        /// <summary>
        /// Returns copy of this noun
        /// </summary>
        /// <returns>Copy of this</returns>
        public Noun Copy()
        {
            var noun = new Noun(this.Id, this.Lemma, this.DependencyType, this.EdgeFactory, this.ElementFactory, this.Manager, this.Width, this.Height);

            noun.Extensions.AddRange(this.Extensions);
            noun.Suffixes.AddRange(this.Suffixes);
            noun.Actions.AddRange(this.Actions);
            noun.Scale = this.Scale;

            return(noun);
        }
コード例 #7
0
ファイル: Adverb.cs プロジェクト: lchaloupsky/Image-generator
 private IProcessable ProcessElement(Noun noun, ISentenceGraph graph)
 {
     return(noun.Process(this, graph));
 }
コード例 #8
0
        private IProcessable ProcessElement(Noun noun, ISentenceGraph graph)
        {
            // If noun is in coordination relation
            if (this.DependencyTypeHelper.IsConjuction(noun.DependencyType) &&
                this.CoordinationTypeHelper.IsMergingCoordination(this.CoordinationType))
            {
                // Try to create new edge between elements
                IPositionateEdge newEdge = this.EdgeFactory.Create(
                    this,
                    noun,
                    new List <string>(),
                    noun.Adpositions.SelectMany(a => a.GetAdpositions()).Select(a => a.ToString()).ToList(),
                    this.DependencyTypeHelper.IsSubject(noun.DependencyType)
                    );

                if (newEdge != null)
                {
                    noun.Adpositions.Clear();
                    graph.AddEdge(newEdge);
                    noun.FinalizeProcessing(graph);
                }
                // If no exists add noun into this set
                else
                {
                    this.GetAllNouns();
                    this.Nouns.Add(noun);
                }

                return(this);
            }

            // If this element is possessive return depending element
            if (this.DependencyTypeHelper.IsPossesive(noun.DependencyType))
            {
                return(this);
            }

            // Let each noun process noun phrase
            if (this.DependencyTypeHelper.IsNounPhrase(noun.DependencyType) || this.DependencyTypeHelper.IsCompound(noun.DependencyType) || this.DependencyTypeHelper.IsName(noun.DependencyType))
            {
                this.Nouns.ForEach(n => n.Process(noun, graph));
                graph.ReplaceVertex(this, noun);

                return(this);
            }

            // If this is negated return depending element
            if (this.IsNegated && this.DependencyTypeHelper.IsObject(this.DependencyType))
            {
                return(noun);
            }

            // Processing relationship between noun and this
            this.DrawableHelper.ProcessEdge(graph, this.EdgeFactory, this, noun, this.Adpositions, noun.Adpositions, this.DependencyTypeHelper.IsSubject(noun.DependencyType), () =>
            {
                // Add to extensions
                noun.DependencyType = "compound";
                this.Nouns.ForEach(n => n.Process(noun, graph));
            });

            // Finalize processed noun
            noun.FinalizeProcessing(graph);

            return(this);
        }
コード例 #9
0
 protected virtual IProcessable ProcessElement(Noun noun, ISentenceGraph graph)
 {
     return(noun.Process(this, graph));
 }