예제 #1
0
        private IProcessable ProcessElement(Verb verb, ISentenceGraph graph)
        {
            // Skip copula
            if (this.DependencyTypeHelper.IsCopula(verb.DependencyType))
            {
                return(this);
            }

            IProcessable processElement = this;

            // Process all depending drawables of the verb
            if (verb.DependingDrawables.Count != 0)
            {
                verb.DependingDrawables.ForEach(dd => processElement = processElement.Process(dd, graph));
                verb.DependingDrawables.Clear();
            }

            // Process all related actions
            verb.RelatedActions.ForEach(ra => processElement.Process(ra, graph));
            verb.RelatedActions.Clear();

            // Process non used adposition
            if (verb.DrawableAdposition != null)
            {
                processElement.Process(verb.DrawableAdposition, graph);
                verb.DrawableAdposition = null;
            }

            // Replace verb object in the graph
            if (verb.Object != null)
            {
                if (verb.Object is NounSet)
                {
                    ((NounSet)verb.Object).Nouns.ForEach(n =>
                    {
                        if (graph.Vertices.Contains(n))
                        {
                            graph.ReplaceVertex((IDrawable)processElement, n);
                        }
                    });
                }

                if (graph.Vertices.Contains((IDrawable)verb.Object))
                {
                    graph.ReplaceVertex((IDrawable)processElement, (IDrawable)verb.Object);
                }
            }

            // Process only non negated verbs
            if (!verb.IsNegated && processElement == this)
            {
                foreach (var noun in this.Nouns)
                {
                    noun.Process(verb, graph);
                }
            }

            return(processElement);
        }
예제 #2
0
        private IProcessable ProcessElement(Verb verb, ISentenceGraph graph)
        {
            // skip copula
            if (this.DependencyHelper.IsCopula(verb.DependencyType))
            {
                return(this);
            }

            IProcessable processElement = this;

            // Don't process negated verb
            if (!verb.IsNegated)
            {
                this.Actions.Add(verb);
            }

            // Process all depending drawables
            if (verb.DependingDrawables.Count != 0)
            {
                verb.DependingDrawables.ForEach(dd => processElement = processElement.Process(dd, graph));
                verb.DependingDrawables.Clear();
            }

            // Process all related actions
            verb.RelatedActions.ForEach(ra => processElement.Process(ra, graph));
            verb.RelatedActions.Clear();

            // Process unprocessed adposition
            if (verb.DrawableAdposition != null)
            {
                processElement.Process(verb.DrawableAdposition, graph);
            }

            // Replace verb object in the graph
            if (verb.Object != null)
            {
                if (verb.Object is NounSet ns)
                {
                    ns.Nouns.ForEach(n =>
                    {
                        if (graph.Vertices.Contains(n))
                        {
                            graph.ReplaceVertex((IDrawable)processElement, n);
                        }
                    });
                }

                if (graph.Vertices.Contains((IDrawable)verb.Object))
                {
                    graph.ReplaceVertex((IDrawable)processElement, (IDrawable)verb.Object);
                }
            }

            return(processElement);
        }
예제 #3
0
        private IProcessable ProcessElement(Numeral num, ISentenceGraph graph)
        {
            IProcessable processElem = this;

            num.DependingDrawables.ForEach(dd => processElem = processElem.Process(dd, graph));
            num.DependingActions.ForEach(da => processElem   = processElem.Process(da, graph));
            this.Process(num.DependingNumeral, graph);

            // Process appositional
            if (this.DependencyHelper.IsAppositional(num.DependencyType))
            {
                return(processElem);
            }

            // Process numeral expressing part of noun phrase
            if (this.DependencyHelper.IsNounPhrase(this.DependencyType) || this.DependencyHelper.IsCompound(this.DependencyType))
            {
                this.Extensions.Add(num);
                return(processElem);
            }

            // We don't process time
            if (this.DependencyHelper.IsTime(num.DependencyType))
            {
                return(processElem);
            }

            // Add extension if numeral is not modifying number of instances
            if (!this.DependencyHelper.IsNumeralModifier(num.DependencyType))
            {
                if (num.Id > this.Id)
                {
                    this.Suffixes.Add(num);
                }
                else
                {
                    this.Extensions.Add(num);
                }

                return(processElem);
            }

            // no need to create noun set
            if (num.GetValue() <= 1)
            {
                return(processElem);
            }

            // Create new noun with given number of values
            return(new NounSet(this.ElementFactory, this.EdgeFactory, this, num.GetValue()));
        }
예제 #4
0
        /// <summary>
        /// Method for compressing dependency tree edges into other representation
        /// </summary>
        /// <param name="tree">tree to be compressed</param>
        /// <param name="graph">new graph to be created</param>
        /// <param name="element">actual processed element</param>
        /// <returns>Element with processed its dependencies</returns>
        private IProcessable CompressDependencyTree(Dictionary <int, List <IProcessable> > tree, SentenceGraph graph, IProcessable element)
        {
            if (!tree.ContainsKey(element.Id))
            {
                return(element);
            }

            // Adpositions have different priorities
            if (element is Adposition)
            {
                this.Comparer.IsAdposition = true;
            }
            else
            {
                this.Comparer.IsAdposition = false;
            }

            // sorting dependencies before they are processed
            tree[element.Id].Sort(this.Comparer);

            // processing each dependency
            foreach (var vertex in tree[element.Id])
            {
                element = element.Process(CompressDependencyTree(tree, graph, vertex), graph);
            }

            return(element);
        }
예제 #5
0
        static void Main(string[] args)
        {
            using (IDbConnection connection = ConnectionFactory.CreateConnection())
            {
                if (args.Length == 0)
                {
                    Console.WriteLine("ERROR: an argument must be given.");
                    return;
                }
                int          jobId        = Convert.ToInt32(args[0]);
                ProcessingVO processingVO = processingDAO.Get(jobId);

                processingBO = CreateProcessing(processingVO);
                processingBO?.Process();
            }
        }
예제 #6
0
        void OnThread()
        {
            while (true)
            {
                System.Threading.Thread.Sleep(_periodMs);

                if (_processable != null)
                {
                    _processable.Process();
                }
                else if (_loopable != null)
                {
                    _loopable.OnLoop();
                }
            }
        }
예제 #7
0
 private static void Run(string[] args)
 {
     jobId = Convert.ToInt32(args[0]);
     LoadProcessingDefinitions(jobId, DEFAULT_LOAD_MODE);
     processingBO?.Process();
 }
예제 #8
0
 public V Process(T input)
 {
     return(toProcess.Process(input));
 }
예제 #9
0
 public static int Process(IProcessable processable, int i)
 {
     return(processable.Process(i));
 }