private void ExecuteVerbNode(CGNode node, IEnumerable <CGRelation> out_relations)
        {
            //if node is not a verb we can not assign any role
            var currentPath = System.IO.Path.Combine(this.propbankPath, node.nosuffix) + ".xml";

            if (!System.IO.File.Exists(currentPath))
            {
                foreach (var item in out_relations)
                {
                    ManageNotFoundArg(item);
                }
                return;
            }
            var str = System.IO.File.ReadAllText(currentPath);

            var propbankelements = XElement.Parse(str);


            //00 scenarios
            var index = int.Parse(node.text.Replace(node.nosuffix + "-", "")) - 1;

            if (index < 0)
            {
                this.graph.log += "double zero " + node.text;
                foreach (var item in out_relations)
                {
                    ManageNotFoundArg(item);
                }
                return;
            }

            var propbankelement = (from c in propbankelements.Elements("predicate").Elements("roleset")
                                   select c).ElementAtOrDefault(index);

            foreach (var relation in out_relations)
            {
                if (relation.label.Contains("ARG"))
                {
                    var number = relation.label.Replace("ARG", "");

                    if (propbankelement == null)
                    {
                        ManageNotFoundArg(relation);
                    }
                    else
                    {
                        var roleelement = (from c in propbankelement.Elements("roles").Elements("role")
                                           where c.Attribute("n").Value == number
                                           select c).FirstOrDefault();
                        if (roleelement != null)
                        {
                            relation.description = roleelement.Attribute("descr").Value.Replace("/", "").Replace("'", "").Replace(@"\", "");
                            relation.f           = roleelement.Attribute("f").Value.ToLower();

                            var vnx = roleelement.Element("vnrole");
                            if (vnx != null)
                            {
                                relation.vncls          = vnx.Attribute("vncls").Value;
                                relation.vntheta        = vnx.Attribute("vntheta").Value;
                                relation.conceptualrole = relation.vntheta.ToLower();
                            }
                            else
                            {
                                if (relation.f == "pag")
                                {
                                    relation.conceptualrole = "agent";
                                }
                                else if (relation.f == "ppt")
                                {
                                    relation.conceptualrole = "patient";
                                }
                                else if (relation.f == "gol")
                                {
                                    relation.conceptualrole = "goal";
                                }
                                else if (relation.f == "loc")
                                {
                                    relation.conceptualrole = "location";
                                }
                                else if (relation.f == "dir")
                                {
                                    relation.conceptualrole = "direction";
                                }
                                else if (relation.f == "ext")
                                {
                                    relation.conceptualrole = "extend";
                                }
                                else if (relation.f == "prd")
                                {
                                    relation.conceptualrole = "location";
                                }
                                else if (relation.f == "mnr")
                                {
                                    relation.conceptualrole = "manner";
                                }
                                else if (relation.f == "adv")
                                {
                                    relation.conceptualrole = "adverb";
                                }
                                else if (relation.f == "cau")
                                {
                                    relation.conceptualrole = "cause";
                                }
                                else if (relation.f == "vsp")
                                {
                                    relation.conceptualrole = "vsp";
                                }
                                else if (relation.f == "prp")
                                {
                                    relation.conceptualrole = "purpose";
                                }
                                else if (relation.f == "com")
                                {
                                    relation.conceptualrole = "agent";
                                }
                                else if (relation.f == "tmp")
                                {
                                    relation.conceptualrole = "tmp";
                                }
                                else
                                {
                                    throw new ApplicationException("no info");
                                }
                            }
                        }
                        else
                        {
                            ManageNotFoundArg(relation);
                        }
                    }
                }
                else
                {
                    ManageNotFoundArg(relation);
                }
            }
        }
Ejemplo n.º 2
0
        public CGExpression BuildVerbExpression(CGNode target, string role, CGNode previous)
        {
            CGExpression expression = new CGExpression(target, role);

            expression.Mods      = this.FindByHead(target.id, "mod");
            expression.Locations = this.FindByHead(target.id, "location");
            expression.Degree    = this.FindByHead(target.id, "degree");
            expression.Manner    = this.FindByHead(target.id, "manner");
            var ins = this.Relations.Where(c => c.Tail == target.id &&
                                           (previous != null && c.Head != previous.id));

            foreach (var item in ins)
            {
                var head = this.Nodes.Where(c => c.id == item.Head).Single();
                if (item.conceptualrole == "patient")
                {
                    var tmp = this.Relations.Where(c => c.Tail == item.Head).Count();
                    if (tmp == 0)
                    {
                        expression.Adverbs.Add(head);
                    }
                }
                else if (item.conceptualrole != "mod" &&
                         item.conceptualrole != "location" &&
                         item.conceptualrole != "degree" &&
                         item.conceptualrole != "manner" &&
                         item.conceptualrole != "agent" &&
                         item.conceptualrole != "destination" &&
                         item.conceptualrole != "purpose" &&
                         item.conceptualrole != "result" &&
                         item.conceptualrole != "co-patient" &&
                         item.conceptualrole != "experiencer" &&
                         item.conceptualrole != "theme" &&
                         item.conceptualrole != "goal" &&
                         item.conceptualrole != "instrument" &&
                         item.conceptualrole != "op")
                {
                    throw new ApplicationException("delete");
                }
            }
            var outs = this.Relations.Where(c => c.Head == target.id);

            foreach (var item in outs)
            {
                var tail = this.Nodes.Where(c => c.id == item.Tail).Single();
                if (item.conceptualrole != "mod" &&
                    item.conceptualrole != "location" &&
                    item.conceptualrole != "degree" &&
                    item.conceptualrole != "manner" &&
                    item.conceptualrole != "agent" &&
                    item.conceptualrole != "destination" &&
                    item.conceptualrole != "stimulus" &&
                    item.conceptualrole != "purpose" &&
                    item.conceptualrole != "result" &&
                    item.conceptualrole != "patient" &&
                    item.conceptualrole != "co-patient" &&
                    item.conceptualrole != "experiencer" &&
                    item.conceptualrole != "theme" &&
                    item.conceptualrole != "goal" &&
                    item.conceptualrole != "source" &&
                    item.conceptualrole != "topic" &&
                    item.conceptualrole != "asset" &&
                    item.conceptualrole != "instrument" &&
                    item.conceptualrole != "op" &&
                    item.conceptualrole != "attribute" &&
                    item.conceptualrole != "prep-under" &&
                    item.conceptualrole != "predicate" &&
                    item.conceptualrole != "end")
                {
                    throw new ApplicationException("delete");
                }
            }
            return(expression);
        }
Ejemplo n.º 3
0
 public void AddNode(CGNode Node)
 {
     this._Nodes.Add(Node);
 }
Ejemplo n.º 4
0
 public void RemoveSubGraph(CGNode Start)
 {
     this.RecursiveRemoveSubGraph(Start);
 }
Ejemplo n.º 5
0
 public bool IsLeaf(CGNode Node)
 {
     return(this.GetOutRelations(Node).Count() == 0);
 }
Ejemplo n.º 6
0
        public IEnumerable <CGRelation> GetInRelations(CGNode Node)
        {
            var relations = this.Relations.Where(c => c.Tail == Node.id).ToList();

            return(relations);
        }
Ejemplo n.º 7
0
 public void AddMod(CGNode mod)
 {
     this.mods.Add(mod);
     this.rank += mod.pagerank;
 }
Ejemplo n.º 8
0
 public void AddText(CGNode node)
 {
     this.text  = node;
     this.rank += node.pagerank;
 }