Example #1
0
        public override IProcessable FinalizeProcessing(ISentenceGraph graph)
        {
            if (this.Image != null)
            {
                return(this);
            }

            this.GetImage();

            // If this is plural finalize wih noun set
            IPositionateEdge newEdge;

            if (this.IsPlural)
            {
                var finalizingElement = new NounSet(this.ElementFactory, this.EdgeFactory, this, NumberOfInstances);
                newEdge = this.EdgeFactory.Create(finalizingElement, this.Adpositions.SelectMany(a => a.GetAdpositions()).Select(a => a.ToString()).ToList());
                return(finalizingElement);
            }

            // Try to create new absolute edge
            newEdge = this.EdgeFactory.Create(this, this.Adpositions.SelectMany(a => a.GetAdpositions()).Select(a => a.ToString()).ToList());
            if (newEdge != null)
            {
                graph.AddEdge(newEdge);
                this.Adpositions.Clear();
            }

            // Scaling from accumulated scale
            this.Width  = (int)(this.Width * this.Scale);
            this.Height = (int)(this.Height * this.Scale);

            return(this);
        }
Example #2
0
        private IProcessable ProcessElement(NounSet nounSet, ISentenceGraph graph)
        {
            // Check if it is subject
            if (this.DependencyHelper.IsSubject(nounSet.DependencyType))
            {
                if (this.DrawableAdposition != null)
                {
                    nounSet.Process(this.DrawableAdposition, graph);
                    this.DrawableAdposition = null;
                }

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

            // Check if it is object
            if (this.DependencyHelper.IsObject(nounSet.DependencyType) && this.Object == null)
            {
                this.Object = nounSet;
            }
            else
            {
                this.DependingDrawables.Add(nounSet);
            }

            return(this);
        }
Example #3
0
        private IProcessable ProcessElement(NounSet nounSet, ISentenceGraph graph)
        {
            // If noun set is in coordination relation
            if (this.DependencyTypeHelper.IsConjuction(nounSet.DependencyType) &&
                this.CoordinationTypeHelper.IsMergingCoordination(this.CoordinationType))
            {
                // Try create edge between elements
                IPositionateEdge newEdge = this.EdgeFactory.Create(
                    this,
                    nounSet,
                    new List <string>(),
                    nounSet.Adpositions.SelectMany(a => a.GetAdpositions()).Select(a => a.ToString()).ToList(),
                    this.DependencyTypeHelper.IsSubject(nounSet.DependencyType)
                    );

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

                // If no edge exists merge them
                this.GetAllNouns();
                this.Nouns.AddRange(nounSet.GetAllNouns());
                nounSet.Nouns.Clear();
                graph.ReplaceVertex(this, nounSet);
                return(this);
            }

            // Part of this noun
            if (this.DependencyTypeHelper.IsCompound(nounSet.DependencyType) || this.DependencyTypeHelper.IsNounPhrase(nounSet.DependencyType) || this.DependencyTypeHelper.IsName(nounSet.DependencyType))
            {
                this.Nouns.ForEach(n => n.Process(nounSet, graph));
                graph.ReplaceVertex(this, nounSet);

                return(this);
            }

            // Return noun set if this is negated
            if (this.IsNegated && this.DependencyTypeHelper.IsObject(this.DependencyType))
            {
                return(nounSet);
            }

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

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

            return(this);
        }
Example #4
0
 private IProcessable ProcessElement(NounSet nounSet, ISentenceGraph graph)
 {
     return(nounSet.Process(this, graph));
 }
Example #5
0
 protected virtual IProcessable ProcessElement(NounSet nounSet, ISentenceGraph graph)
 {
     return(nounSet.Process(this, graph));
 }