public void TestSimpleQuery() { var gn = new QueryGraphNet("Test_Query", maxNumberOfPaths: 10, maxPathLenght: 20); gn.LimitNumberOfPaths = true; gn.PrefixLoader = (uri, graph) => { graph.Add("p:name", "http://www.w3.org/2000/01/rdf-schema#domain", "p:Place"); graph.Add("p:code", "http://www.w3.org/2000/01/rdf-schema#domain", "p:Place"); var net = graph as PredicateNet; net.Add(net.GetPrefixNamespaceNode(), net.Node("has"), graph.Node("p:name")); net.Add(net.GetPrefixNamespaceNode(), net.Node("has"), graph.Node("p:code")); }; //TODO: move this code into the QueryGraphNet as really it is core to how it works gn.RegisterDynamic("parse", (node, graph) => { gn.QueryText = node.ShortId.ToString().Replace("http://graph.network.com/ld/", ""); var lastWord = gn.LastWordAsNode(); if (lastWord != null && node.Edges.Count == 0) { node.AddEdge(graph.Node("current"), lastWord); } Node.BaseOnAdd(node, graph); }); gn.DefaultInput = "parse"; gn.TrainFromQueries( "PREFIX p: <http://test.com/places/> select * where { ?s a p:City . ?s p:name ?mayor }", "PREFIX p: <http://test.com/places/> select * where { ?s a p:Country . ?s p:name ?flag }" ); Assert.AreEqual("where", gn.Predict("PREFIX p: <http://test.com/places/> SELECT *")); Assert.AreEqual("{", gn.Predict("PREFIX p: <http://test.com/places/> SELECT * WHERE")); Assert.AreEqual("name", gn.Predict("PREFIX p: <http://test.com/places/> SELECT * WHERE {?s p:}")); //TODO: Assert.AreEqual("p:name", gn.Predict("PREFIX p: <http://test.com/places/> SELECT * WHERE {?s }")); }