public void Execute(CGGraph graph)
 {
     foreach (var item in graph.Relations.Where(c => c.label == "null_edge").ToList())
     {
         graph.RemoveRelation(item);
     }
 }
Example #2
0
        public void Execute(CGGraph graph)
        {
            List <CGRelation> deletes = new List <CGRelation>();

            var relations = from c in graph.Relations.Where(c => c.label.Contains("-of"))
                            select c;

            foreach (var item in relations)
            {
                var head = graph.Nodes.Where(c => c.id == item.Head).First();
                var tail = graph.Nodes.Where(c => c.id == item.Tail).First();
                if (!tail.text.Contains("-0"))
                {
                    //deletes.Add(item);
                }
                else
                {
                    item.log  += string.Format("OF relation {0};", item.label);
                    item.label = item.label.Replace("-of", "");
                    var tmp = item.Head;
                    item.Head = item.Tail;
                    item.Tail = tmp;
                }
            }
            foreach (var item in deletes)
            {
                graph.RemoveRelation(item);
            }
        }
Example #3
0
        public void Execute(CGGraph graph)
        {
            List <CGNode> deletes = new List <CGNode>();

            foreach (var node in graph.Nodes)
            {
                if (node.text == "null_tag")
                {
                    deletes.Add(node);
                    foreach (var inR in graph.Relations.Where(c => c.Head == node.id).ToList())
                    {
                        graph.RemoveRelation(inR);
                    }
                    foreach (var outR in graph.Relations.Where(c => c.Tail == node.id).ToList())
                    {
                        graph.RemoveRelation(outR);
                    }
                }
            }
            foreach (var item in deletes)
            {
                graph.RemoveNode(item);
            }
        }
Example #4
0
        public void Execute()
        {
            List <CGRelation> deletes = new List <CGRelation>();

            foreach (var item in this.graph.Relations)
            {
                if (item.label.StartsWith("range"))
                {
                    deletes.Add(item);
                }
            }
            foreach (var item in deletes)
            {
                graph.RemoveRelation(item);
            }
        }
Example #5
0
        public void Execute()
        {
            List <CGRelation> deletes = new List <CGRelation>();

            foreach (var item in this.graph.Relations)
            {
                if (item.label == "value")
                {
                    deletes.Add(item);
                }
            }
            foreach (var item in deletes)
            {
                graph.RemoveRelation(item);
            }
        }
Example #6
0
        public void Execute()
        {
            List <CGRelation> deletes = new List <CGRelation>();

            foreach (var item in this.graph.Relations.ToList())
            {
                if (item.label == "quant")
                {
                    var node = this.graph.Nodes.Where(c => c.id == item.Tail).Single();
                    this.graph.RecursiveRemoveSubGraph(node);
                }
            }
            foreach (var item in deletes)
            {
                graph.RemoveRelation(item);
            }
        }
Example #7
0
        public void Execute()
        {
            List <CGRelation> deletes = new List <CGRelation>();

            foreach (var item in this.graph.Relations)
            {
                if (item.label.StartsWith("domain"))
                {
                    item.f              = item.label;
                    item.description    = item.label;
                    item.conceptualrole = item.label;
                }
            }
            foreach (var item in deletes)
            {
                graph.RemoveRelation(item);
            }
        }
Example #8
0
        private void GraphFusion(CGGraph graph, IEnumerable <IGrouping <string, CGNode> > groups)
        {
            foreach (var g in groups)
            {
                //survivor
                List <CGNode>     deletes           = new List <CGNode>();
                List <CGRelation> relations_deletes = new List <CGRelation>();
                List <CGRelation> relations_news    = new List <CGRelation>();

                var max = g.OrderByDescending(c => c.rstweight).First();
                foreach (var node in g)
                {
                    if (node.id == max.id)
                    {
                        continue;
                    }
                    max.AddFusionNode(node);
                    deletes.Add(node);
                }
                foreach (var node in g)
                {
                    if (node.id == max.id)
                    {
                        continue;
                    }

                    var inrelations = from c in graph.Relations where c.Tail == node.id select c;
                    foreach (var item in inrelations)
                    {
                        var n = item.Clone();
                        n.Tail = max.id;
                        relations_deletes.Add(item);

                        if (deletes.Where(c => c.id == n.Head).Count() == 0)
                        {
                            relations_news.Add(n);
                        }
                    }
                    var outrelations = from c in graph.Relations where c.Head == node.id select c;
                    foreach (var item in outrelations)
                    {
                        var n = item.Clone();
                        n.Head = max.id;
                        relations_deletes.Add(item);
                        if (deletes.Where(c => c.id == n.Tail).Count() == 0)
                        {
                            relations_news.Add(n);
                        }
                    }
                }
                foreach (var item in relations_deletes)
                {
                    graph.RemoveRelation(item);
                }
                foreach (var item in relations_news)
                {
                    graph.AddRelation(item);
                }

                foreach (var item in deletes)
                {
                    graph.RemoveNode(item);
                }
            }
        }