コード例 #1
0
        public static AmrTerm GetAmrTerm(IGraph g, AmrNode node)
        {
            AmrTerm           result  = new AmrTerm();
            SparqlQueryParser qparser = new SparqlQueryParser();
            var         str           = "SELECT ?p WHERE { <" + node.uriid + ">  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?p }";
            SparqlQuery q             = qparser.ParseFromString(str);
            var         rset          = (SparqlResultSet)g.ExecuteQuery(q);
            var         SB            = new StringBuilder();

            if (rset.Result && rset.Results.Count > 0)
            {
                foreach (var set in rset.Results)
                {
                    foreach (var r in set)
                    {
                        result.uriid = r.Value.ToString();
                    }
                }
            }
            qparser = new SparqlQueryParser();
            str     = "SELECT ?p WHERE { <" + result.uriid + ">  <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ?p }";
            q       = qparser.ParseFromString(str);
            rset    = (SparqlResultSet)g.ExecuteQuery(q);

            if (rset.Result && rset.Results.Count > 0)
            {
                foreach (var set in rset.Results)
                {
                    foreach (var r in set)
                    {
                        result.type = r.Value.ToString();
                    }
                }
            }


            //s http://amr.isi.edu/frames/ld/v1.2.2/dedicate-01
            //x http://www.w3.org/1999/02/22-rdf-syntax-ns#type
            //p http://amr.isi.edu/rdf/core-amr#Frame

            return(result);
        }
コード例 #2
0
 public void AddRoot(IGraph graph)
 {
     Root       = new AmrNode();
     Root.uriid = Helper.GetAmrRoot(graph, this);
     Root.Term  = Helper.GetAmrTerm(graph, this.Root);
 }