private GraphNet LoadSparqlGraphNet()
        {
            var gn = new SparqlSyntaxNet();

            //gn.MaxNumberOfPaths = 5;
            //gn.MaxPathLenght = 10;
            gn.RegisterDynamic("parse", (node, graph) => {
                node.ShortId = node.ShortId.Replace(SparqlSyntaxNet.IRI_PREFIX, "");
                var q        = new QueryGraphNet("x")
                {
                    QueryText = node.ShortId
                };
                var current = q.LastWordAsNode();
                if (current != null)
                {
                    node.AddEdge(graph.Node("current"), graph.Node(current.ShortId));
                }

                Node.BaseOnAdd(node, graph);
            });
            gn.DefaultInput = "parse";

            gn.TrainFromQueries(
                "select * where { ?s ?p ?o }",
                "select ?p where { ?s ?p ?o }",
                "select * where { ?s <http://test.com/name> ?name }",
                "select * where { ?s <http://test.com/other> ?other }"
                );


            return(gn);
        }
Esempio n. 2
0
        public void TestTextMatcher()
        {
            var gn = new SparqlSyntaxNet();

            gn.MaxNumberOfPaths = 5;
            gn.MaxPathLenght    = 10;
            gn.TrainFromQueries(
                "select * where { ?s ?p ?o }",
                "select distinct ?p where { ?s ?p ?o }",
                "select * where { ?s <http://test.com/name> ?name }"
                );

            Assert.AreEqual("select", gn.Predict("s"));
        }
Esempio n. 3
0
        public void TestBasicSyntax()
        {
            var gn = new SparqlSyntaxNet();

            gn.MaxNumberOfPaths = 5;
            gn.MaxPathLenght    = 10;
            gn.TrainFromQueries(
                "select * where { ?s ?p ?o }",
                "select distinct ?p where { ?s ?p ?o }",
                "select * where { ?s <http://test.com/name> ?name }"
                );

            Assert.AreEqual("*", gn.Predict("select"));
            Assert.AreEqual("where", gn.Predict("*"));
            Assert.AreEqual("{", gn.Predict("where"));
            Assert.AreEqual("?s", gn.Predict("{"));
            Assert.AreEqual("?p", gn.Predict("?s"));
            Assert.AreEqual("?o", gn.Predict("?p"));
            Assert.AreEqual("}", gn.Predict("?o"));
            Assert.AreEqual("?p", gn.Predict("distinct"));
        }