示例#1
0
        private void NavigateAttribute(List <CGVerbTerm> list, CGNode Target, CGGraph graph, int level)
        {
            var out_agents = graph.GetOutRelations(Target);

            foreach (var rel in out_agents)
            {
                var item = graph.Nodes.Where(c => c.id == rel.Tail).Single();
                if (rel.conceptualrole == "mod" ||
                    rel.conceptualrole == "manner" ||
                    rel.conceptualrole == "op" ||
                    rel.conceptualrole == "domain" ||
                    rel.conceptualrole == "poss" ||
                    rel.conceptualrole == "direction" ||
                    rel.conceptualrole == "location")
                {
                    if (list.Where(c => c.Node.id == item.id).Count() == 0 &&
                        list.Where(c => c.Node.text == item.text).Count() == 0)
                    {
                        var wrapper = new CGVerbTerm(item, rel, level + 1);
                        list.Add(wrapper);
                        NavigateAttribute(list, item, graph, level + 1);
                    }
                }
                else
                {
                    this.AttributesLoss.Add(string.Format("Text :{0} / conceptualroles:{1} / Item Text: {2} / Level {3}", Target.text, rel.conceptualrole, item.text, level));
                }
            }
        }
示例#2
0
        public void GenerateAgents(CGGraph graph)
        {
            var out_agents = graph.GetOutRelationsByConceptualRole(this.Verb, "agent", "co-agent", "experiencer",
                                                                   "stimulus");

            foreach (var rel in out_agents)
            {
                var node    = graph.Nodes.Where(c => c.id == rel.Tail).Single();
                var list    = new List <CGVerbTerm>();
                var wrapper = new CGVerbTerm(node, rel, 0);
                list.Add(wrapper);
                NavigateAgent(list, node, graph, 0);
                this.Agents.Add(list);
            }
            var in_agents = graph.GetInRelationsByConceptualRole(this.Verb, "agent-of");

            foreach (var rel in in_agents)
            {
                var node    = graph.Nodes.Where(c => c.id == rel.Head).Single();
                var list    = new List <CGVerbTerm>();
                var wrapper = new CGVerbTerm(node, rel, 0);
                list.Add(wrapper);
                NavigateAgent(list, node, graph, 0);
                this.Agents.Add(list);
            }
        }
示例#3
0
        public static void ConceptualSummaryDebug(string InputDir, string AmrDir, string OutputDir)
        {
            var files = Directory.GetFiles(InputDir, "*.txt");

            foreach (var file in files)
            {
                var amrfile = Path.Combine(AmrDir, Path.GetFileNameWithoutExtension(file) + ".txt.all.basic-abt-brown-verb.parsed");
                if (File.Exists(amrfile))
                {
                    var sanityAMR = SanityXml.Sanity(File.ReadAllText(amrfile));
                    var reader    = new AMR.AMRReader();
                    var amrdoc    = reader.ReadContent(sanityAMR);
                    amrdoc.LoadDummyRSTInformation();
                    CGGraph cgraph = new CGGraph(Path.GetFileNameWithoutExtension(file), @"D:\Tesis2016\Propbank\frames", amrdoc.Graphs.Sum(c => c.Nodes.Count));
                    cgraph.ReadAMR(amrdoc);
                    cgraph.Digest();


                    StringBuilder sb = new StringBuilder();
                    sb.AppendLine(File.ReadAllText(file));
                    sb.AppendLine("==================summary==========================");
                    sb.AppendLine(cgraph.Summary());
                    sb.AppendLine("==================debug==========================");
                    sb.AppendLine(cgraph.SummaryDebug());

                    File.WriteAllText(Path.Combine(OutputDir, Path.GetFileNameWithoutExtension(file) + ".txt"), sb.ToString());
                }
            }
            Console.ReadLine();
        }
示例#4
0
        public static void ConceptualRSTNLG(string InputDir, string RSTDir, string AmrDir, string OutputDir)
        {
            var files = Directory.GetFiles(InputDir, "*.txt");

            foreach (var file in files)
            {
                var amrfile = Path.Combine(AmrDir, Path.GetFileNameWithoutExtension(file) + ".txt.all.basic-abt-brown-verb.parsed");
                if (File.Exists(amrfile))
                {
                    var sanity = SanityXml.Sanity(File.ReadAllText(Path.Combine(RSTDir, Path.GetFileNameWithoutExtension(file) + ".txt.xml.jarvis")));

                    RST.RSTReader rstreader   = new RST.RSTReader();
                    var           rstdocument = rstreader.ReadDocumentContent(sanity, Path.GetFileNameWithoutExtension(file));
                    rstdocument.EvaluateODonell(false);
                    var sanityAMR = SanityXml.Sanity(File.ReadAllText(amrfile));
                    var reader    = new AMR.AMRReader();
                    var amrdoc    = reader.ReadContent(sanityAMR);
                    amrdoc.LoadRSTInformation(rstdocument);
                    CGGraph cgraph = new CGGraph(Path.GetFileNameWithoutExtension(file), @"D:\Tesis2016\Propbank\frames", amrdoc.Graphs.Sum(c => c.Nodes.Count));
                    cgraph.ReadAMR(amrdoc);
                    cgraph.Digest();
                    File.WriteAllText(Path.Combine(OutputDir, Path.GetFileNameWithoutExtension(file) + ".txt"), cgraph.GenerateMetadataNLG());
                }
            }
            Console.ReadLine();
        }
示例#5
0
        public void GenerateAttribute(CGGraph graph)
        {
            var out_themes = graph.GetOutRelationsByConceptualRole(this.Verb, "attribute");

            foreach (var rel in out_themes)
            {
                var node    = graph.Nodes.Where(c => c.id == rel.Tail).Single();
                var list    = new List <CGVerbTerm>();
                var wrapper = new CGVerbTerm(node, rel, 0);
                list.Add(wrapper);
                NavigateAttribute(list, node, graph, 0);
                this.Attributes.Add(list);
            }
        }
示例#6
0
        public void GenerateGoal(CGGraph graph)
        {
            var out_themes = graph.GetOutRelationsByConceptualRole(this.Verb, "goal", "purpose", "destination", "asset");

            foreach (var rel in out_themes)
            {
                var node    = graph.Nodes.Where(c => c.id == rel.Tail).Single();
                var list    = new List <CGVerbTerm>();
                var wrapper = new CGVerbTerm(node, rel, 0);
                list.Add(wrapper);
                NavigateGoal(list, node, graph, 0);
                this.Goal.Add(list);
            }
        }
示例#7
0
        public void GeneratePatients(CGGraph graph)
        {
            var out_patients = graph.GetOutRelationsByConceptualRole(this.Verb, "patient", "co-patient",
                                                                     "recipient", "predicate");

            foreach (var rel in out_patients)
            {
                var node    = graph.Nodes.Where(c => c.id == rel.Tail).Single();
                var list    = new List <CGVerbTerm>();
                var wrapper = new CGVerbTerm(node, rel, 0);
                list.Add(wrapper);
                NavigatePatient(list, node, graph, 0);
                this.Patients.Add(list);
            }
        }
示例#8
0
        public void GenerateVerbs(CGGraph graph)
        {
            var out_verbs = graph.GetOutRelations(this.Verb);

            foreach (var rel in out_verbs)
            {
                if (rel.conceptualrole == "mod" ||
                    rel.conceptualrole == "manner" ||
                    rel.conceptualrole == "time")
                {
                    var node    = graph.Nodes.Where(c => c.id == rel.Tail).Single();
                    var wrapper = new CGVerbTerm(node, rel, 0);
                    this.VerbAttributes.Add(wrapper);
                }
                else
                {
                    this.AttributesLoss.Add(string.Format("{0} {1} {2} {3}", Verb.id, Verb.text, rel.conceptualrole, rel.Tail));
                }
            }
        }
        void CBEditCrossButton()
        {
            if (DTGUI.IsLayout)
            {
                mShowEditButton = (Target.IsConfigured && Target.InCross.SourceSlot().ExternalInput != null && Target.InCross.SourceSlot().ExternalInput.SupportsIPE);
            }

            if (mShowEditButton)
            {
                EditorGUI.BeginChangeCheck();
                mEditCross = GUILayout.Toggle(mEditCross, "Edit Cross", EditorStyles.miniButton);
                if (EditorGUI.EndChangeCheck())
                {
                    if (mEditCross)
                    {
                        CGGraph.SetIPE(Target.Cross, this);
                    }
                    else
                    {
                        CGGraph.SetIPE();
                    }
                }
            }
        }
示例#10
0
        public void SaveCG(CGGraph Graph)
        {
            using (var client = this.CreateClient())
            {
                client.Connect();

                client.Cypher.Create("(a:CGGraph {newObject})")
                .WithParam("newObject", Graph)
                .ExecuteWithoutResults();

                client.Cypher.Match("(a:CGGraph)", "(d:Document)")
                .Where((CGGraph a) => a.name == Graph.name)
                .AndWhere((Common.Document d) => d.name == Graph.name)
                .CreateUnique(string.Format("(d)-[:cg]->(a)"))
                .ExecuteWithoutResults();

                foreach (var node in Graph.Nodes)
                {
                    client.Cypher.Create("(n:CGNode {newObject})")
                    .WithParam("newObject", node)
                    .ExecuteWithoutResults();

                    client.Cypher.Match("(a:CGGraph)", "(n:CGNode)")
                    .Where((CGGraph a) => a.name == Graph.name)
                    .AndWhere((CGNode n) => n.id == node.id)
                    .CreateUnique(string.Format("(a)-[:has]->(n)"))
                    .ExecuteWithoutResults();
                }
                foreach (var relation in Graph.Relations)
                {
                    client.Cypher.Match("(a:CGNode)", "(n:CGNode)")
                    .Where((CGNode a) => a.id == relation.Head)
                    .AndWhere((CGNode n) => n.id == relation.Tail)
                    .CreateUnique(string.Format("(a)-[r:cgrelation {{ label: '{0}', description: '{1}', f:'{2}', vntheta:'{3}', log:'{4}', conceptualrole:'{5}'}} ]->(n)", relation.label, relation.description, relation.f, relation.vntheta, relation.log, relation.conceptualrole))
                    .ExecuteWithoutResults();
                }
                foreach (var aspect in Graph.CGSentences)
                {
                    //client.Cypher.Create("(n:CGAspect {newObject})")
                    //    .WithParam("newObject", aspect)
                    //    .ExecuteWithoutResults();

                    //client.Cypher.Match("(a:CGGraph)", "(n:CGAspect)")
                    //   .Where((CGGraph a) => a.name == Graph.name)
                    //   .AndWhere((CGInformativeAspect n) => n.name == aspect.name)
                    //   .CreateUnique(string.Format("(a)-[:hasaspect]->(n)"))
                    //   .ExecuteWithoutResults();

                    //foreach (var item in aspect.Who)
                    //{
                    //    client.Cypher.Match("(a:CGAspect)", "(n:CGNode)")
                    //   .Where((CGInformativeAspect a) => a.name == aspect.name)
                    //   .AndWhere((CGNode n)=> n.id == item.id)
                    //   .CreateUnique(string.Format("(a)-[r:aspect {{ role:'{0}' }} ]->(n)", "who"))
                    //   .ExecuteWithoutResults();
                    //}
                    //foreach (var item in aspect.What)
                    //{
                    //    client.Cypher.Match("(a:CGAspect)", "(n:CGNode)")
                    //   .Where((CGInformativeAspect a) => a.name == aspect.name)
                    //   .AndWhere((CGNode n) => n.id == item.id)
                    //   .CreateUnique(string.Format("(a)-[r:aspect {{ role:'{0}' }} ]->(n)", "what"))
                    //   .ExecuteWithoutResults();
                    //}
                    //foreach (var item in aspect.Who_affected)
                    //{
                    //    client.Cypher.Match("(a:CGAspect)", "(n:CGNode)")
                    //   .Where((CGInformativeAspect a) => a.name == aspect.name)
                    //   .AndWhere((CGNode n) => n.id == item.id)
                    //   .CreateUnique(string.Format("(a)-[r:aspect {{ role:'{0}' }} ]->(n)", "who_affected"))
                    //   .ExecuteWithoutResults();
                    //}
                    //foreach (var item in aspect.Why)
                    //{
                    //    client.Cypher.Match("(a:CGAspect)", "(n:CGNode)")
                    //   .Where((CGInformativeAspect a) => a.name == aspect.name)
                    //   .AndWhere((CGNode n) => n.id == item.id)
                    //   .CreateUnique(string.Format("(a)-[r:aspect {{ role:'{0}' }} ]->(n)", "why"))
                    //   .ExecuteWithoutResults();
                    //}
                }
            }
        }
示例#11
0
 public CGLinearize(CGGraph graph)
 {
     this.graph = graph;
 }