use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_TFL_GetPath_Tests method test_5.
/**
* Test 5.
*/
@Test
@Order(5)
void test_5() {
try {
Thing _this = source.getThing("londontube:Mornington_Crescent");
PathResults paths = _this.getPaths(":online{1,3}/:hasStationOnLine[eq londontube:Oakleigh_Park]");
assertEquals("", paths.toString());
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_TutorialTests method test_7.
/**
* Test 7.
*/
@SuppressWarnings("resource")
@Test
@Order(7)
void test_7() {
try {
Repository workingRep = Query.createNativeLuceneIntelligentGraphRepository("src/test/resources/datadir/Local_TutorialTests7/");
RepositoryConnection conn = workingRep.getConnection();
conn.setNamespace("", "http://inova8.com/intelligentgraph/example7/");
conn.setNamespace("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
conn.setNamespace("rdfs", "http://www.w3.org/2000/01/rdf-schema#");
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
source.removeGraph("<http://inova8.com/intelligentgraph/example7>");
Graph graph = source.addGraph("<http://inova8.com/intelligentgraph/example7>");
Thing aPerson = graph.getThing(":aPerson");
Thing Another1 = graph.getThing(":Another1");
Thing Another2 = graph.getThing(":Another2");
Thing Another3 = graph.getThing(":Another3");
Thing Another4 = graph.getThing(":Another4");
Thing Another5 = graph.getThing(":Another5");
Thing Another6 = graph.getThing(":Another6");
Thing Another7 = graph.getThing(":Another7");
Thing Another8 = graph.getThing(":Another8");
Thing Another9 = graph.getThing(":Another9");
Thing Another10 = graph.getThing(":Another10");
Thing Another11 = graph.getThing(":Another11");
Thing Another12 = graph.getThing(":Another12");
Thing Location = graph.getThing(":Location");
Thing Maidstone = graph.getThing(":Maidstone").addFact(RDF.TYPE, Location);
Thing Tideswell = graph.getThing(":Tideswell").addFact(RDF.TYPE, Location);
Thing Gender = graph.getThing(":Gender");
Thing Male = graph.getThing(":Male").addFact(RDF.TYPE, Gender);
Thing Female = graph.getThing(":Female").addFact(RDF.TYPE, Gender);
Thing Person = graph.getThing(":Person");
aPerson.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.7", XSD.DOUBLE).addFact(":hasWeight", "62", XSD.DOUBLE).addFact(":hasLocation", Tideswell).addFact(":hasGender", Male).addFact(":hasParent", Another1).addFact(":hasParent", Another3);
Another1.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.9", XSD.DOUBLE).addFact(":hasWeight", "72", XSD.DOUBLE).addFact(":hasLocation", Tideswell).addFact(":hasGender", Male).addFact(":hasParent", Another2);
Another2.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.7", XSD.DOUBLE).addFact(":hasWeight", "65", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male);
Another3.addFact(RDF.TYPE, Person).addFact(":hasHeight", "2", XSD.DOUBLE).addFact(":hasWeight", "59", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female).addFact(":hasParent", Another4);
Another4.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.8", XSD.DOUBLE).addFact(":hasWeight", "47", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male).addFact(":hasParent", Another5).addFact(":hasParent", Another6);
Another5.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.5", XSD.DOUBLE).addFact(":hasWeight", "70", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female);
Another6.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.5", XSD.DOUBLE).addFact(":hasWeight", "56", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male);
Another7.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.7", XSD.DOUBLE).addFact(":hasWeight", "63", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female).addFact(":hasParent", Another5).addFact(":hasParent", Another8).addFact(":hasParent", Another9);
Another8.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.6", XSD.DOUBLE).addFact(":hasWeight", "66", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male);
Another9.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.7", XSD.DOUBLE).addFact(":hasWeight", "46", XSD.DOUBLE).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female).addFact(":hasParent", Another10).addFact(":hasParent", Another11).addFact(":hasParent", Another12);
Another10.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.9", XSD.DOUBLE).addFact(":hasWeight", "61", XSD.DOUBLE).addFact(":hasLocation", Tideswell).addFact(":hasGender", Female);
Another11.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.5", XSD.DOUBLE).addFact(":hasWeight", "61", XSD.DOUBLE).addFact(":hasLocation", Tideswell).addFact(":hasGender", Male);
Another11.addFact(RDF.TYPE, Person).addFact(":hasHeight", "1.8", XSD.DOUBLE).addFact(":hasWeight", "75", XSD.DOUBLE).addFact(":hasLocation", Tideswell).addFact(":hasGender", Female);
assertEquals("http://inova8.com/intelligentgraph/example7/aPerson", aPerson.stringValue());
assertEquals("http://inova8.com/intelligentgraph/example7/Another3", aPerson.getFact(":hasParent[:hasGender :Female]").stringValue());
assertEquals("http://inova8.com/intelligentgraph/example7/Another3", aPerson.getFact(":hasParent[:hasLocation :Maidstone]").stringValue());
assertEquals("http://inova8.com/intelligentgraph/example7/Another3", aPerson.getFact(":hasParent{0,4}/:hasParent[:hasGender :Female]").stringValue());
assertEquals("[ {s=http://inova8.com/intelligentgraph/example7/aPerson, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another3}; {s=http://inova8.com/intelligentgraph/example7/Another4, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another5};]", aPerson.getFacts(":hasParent{0,4}/:hasParent[:hasGender :Female]").toString());
assertEquals("[ {s=http://inova8.com/intelligentgraph/example7/aPerson, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another3}; {s=http://inova8.com/intelligentgraph/example7/Another1, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another2}; {s=http://inova8.com/intelligentgraph/example7/Another3, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another4}; {s=http://inova8.com/intelligentgraph/example7/Another4, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another5}; {s=http://inova8.com/intelligentgraph/example7/Another4, p=http://inova8.com/intelligentgraph/example7/hasParent, o=http://inova8.com/intelligentgraph/example7/Another6};]", aPerson.getFacts(":hasParent{0,4}/:hasParent[:hasLocation :Maidstone]").toString());
PathResults paths = aPerson.getPaths(":hasParent{0,4}/:hasParent[:hasGender :Female]");
assertEquals("Path=[[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another3,DIRECT]\r\n" + "]\r\n" + "Path=[[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another3,DIRECT]\r\n" + "[http://inova8.com/intelligentgraph/example7/Another3,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another4,DIRECT]\r\n" + "[http://inova8.com/intelligentgraph/example7/Another4,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another5,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
paths = aPerson.getPaths(":hasParent{0,4}/:hasParent[:hasLocation :Maidstone]");
String pathString = "";
for (Path path : paths) {
pathString += "Path" + "\n";
for (Edge edge : path) {
pathString += edge.toString() + "\n";
}
}
assertEquals("Path\n" + "[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another3,DIRECT]\n" + "Path\n" + "[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another1,DIRECT]\n" + "[http://inova8.com/intelligentgraph/example7/Another1,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another2,DIRECT]\n" + "Path\n" + "[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another3,DIRECT]\n" + "[http://inova8.com/intelligentgraph/example7/Another3,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another4,DIRECT]\n" + "Path\n" + "[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another3,DIRECT]\n" + "[http://inova8.com/intelligentgraph/example7/Another3,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another4,DIRECT]\n" + "[http://inova8.com/intelligentgraph/example7/Another4,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another5,DIRECT]\n" + "Path\n" + "[http://inova8.com/intelligentgraph/example7/aPerson,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another3,DIRECT]\n" + "[http://inova8.com/intelligentgraph/example7/Another3,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another4,DIRECT]\n" + "[http://inova8.com/intelligentgraph/example7/Another4,http://inova8.com/intelligentgraph/example7/hasParent,http://inova8.com/intelligentgraph/example7/Another6,DIRECT]\n" + "", pathString);
@SuppressWarnings("unused") Thing BMI = graph.getThing(":BMI").addFact(SCRIPT.SCRIPTCODE, "height=_this.getFact(':hasHeight').doubleValue(); _this.getFact(':hasWeight').doubleValue()/(height*height)", SCRIPT.GROOVY);
@SuppressWarnings("unused") Thing familialRelativeBMI = graph.getThing(":FamilialRelativeBMI").addFact(SCRIPT.SCRIPTCODE, "_this.getFact(':hasBMI').doubleValue()/_this.getFacts(':hasParent{0,4}/:hasBMI').average();", SCRIPT.GROOVY);
for (Resource person : graph.getThing(":Person").getFacts("^rdf:type")) {
((Thing) person).addFact(":hasBMI", "<:BMI>", SCRIPT.GROOVY).addFact(":hasFamilialRelativeBMI", "<:FamilialRelativeBMI>", SCRIPT.GROOVY);
}
assertEquals(1.006889937409004, aPerson.getFact(":hasFamilialRelativeBMI").doubleValue());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_PathTutorialTests method test_1.
/**
* Test 1.
*/
@Test
@Order(1)
void test_1() {
try {
Repository workingRep = Query.createNativeLuceneIntelligentGraphRepository("src/test/resources/datadir/Local_PathTutorialTests1/");
RepositoryConnection conn = workingRep.getConnection();
conn.setNamespace("", "http://inova8.com/intelligentgraph/path1/");
conn.setNamespace(XSD.PREFIX, XSD.NAMESPACE);
conn.setNamespace(RDF.PREFIX, RDF.NAMESPACE);
conn.setNamespace(RDFS.PREFIX, RDFS.NAMESPACE);
conn.setNamespace(OWL.PREFIX, OWL.NAMESPACE);
IntelligentGraphRepository source = IntelligentGraphRepository.create(workingRep);
source.removeGraph("<http://inova8.com/intelligentgraph/path1>");
Graph graph = source.addGraph("<http://inova8.com/intelligentgraph/path1>");
Thing aPerson = graph.getThing(":aPerson");
Thing Another1 = graph.getThing(":Another1");
Thing Another2 = graph.getThing(":Another2");
Thing Another3 = graph.getThing(":Another3");
Thing Another4 = graph.getThing(":Another4");
Thing Another5 = graph.getThing(":Another5");
Thing Another6 = graph.getThing(":Another6");
Thing Another7 = graph.getThing(":Another7");
Thing Another8 = graph.getThing(":Another8");
Thing Another9 = graph.getThing(":Another9");
Thing Another10 = graph.getThing(":Another10");
Thing Another11 = graph.getThing(":Another11");
Thing Another12 = graph.getThing(":Another12");
Thing Location = graph.getThing(":Location");
Thing Maidstone = graph.getThing(":Maidstone").addFact(RDF.TYPE, Location);
Thing Tideswell = graph.getThing(":Tideswell").addFact(RDF.TYPE, Location);
Thing Gender = graph.getThing(":Gender");
Thing Male = graph.getThing(":Male").addFact(RDF.TYPE, Gender);
Thing Female = graph.getThing(":Female").addFact(RDF.TYPE, Gender);
Thing Person = graph.getThing(":Person");
aPerson.addFact(RDF.TYPE, Person).addFact(":hasLocation", Tideswell).addFact(":hasGender", Male).addFact(":hasParent", Another1).addFact(":hasParent", Another3);
Another1.addFact(RDF.TYPE, Person).addFact(":hasLocation", Tideswell).addFact(":hasGender", Male).addFact(":hasParent", Another2);
Another2.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male);
Another3.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female).addFact(":hasParent", Another4);
Another4.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male).addFact(":hasParent", Another5).addFact(":hasParent", Another6);
Another5.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female);
Another6.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male);
Another7.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female).addFact(":hasParent", Another5).addFact(":hasParent", Another8).addFact(":hasParent", Another9);
Another8.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Male);
Another9.addFact(RDF.TYPE, Person).addFact(":hasLocation", Maidstone).addFact(":hasGender", Female).addFact(":hasParent", Another10).addFact(":hasParent", Another11).addFact(":hasParent", Another12);
Another10.addFact(RDF.TYPE, Person).addFact(":hasLocation", Tideswell).addFact(":hasGender", Female);
Another11.addFact(RDF.TYPE, Person).addFact(":hasLocation", Tideswell).addFact(":hasGender", Male);
Another12.addFact(RDF.TYPE, Person).addFact(":hasLocation", Tideswell).addFact(":hasGender", Female);
// assertEquals("http://inova8.com/intelligentgraph/path1/aPerson", aPerson.stringValue());
// assertEquals("http://inova8.com/intelligentgraph/path1/Another3", aPerson.getFact(":hasParent[:hasGender :Female]").stringValue());
// assertEquals("http://inova8.com/intelligentgraph/path1/Another3", aPerson.getFact(":hasParent[:hasLocation :Maidstone]").stringValue());
assertEquals("http://inova8.com/intelligentgraph/path1/Another3", aPerson.getFact(":hasParent{0,4}/:hasParent[:hasGender :Female]").stringValue());
assertEquals("[ {s=http://inova8.com/intelligentgraph/path1/aPerson, p=http://inova8.com/intelligentgraph/path1/hasParent, o=http://inova8.com/intelligentgraph/path1/Another3}; {s=http://inova8.com/intelligentgraph/path1/Another4, p=http://inova8.com/intelligentgraph/path1/hasParent, o=http://inova8.com/intelligentgraph/path1/Another5};]", aPerson.getFacts(":hasParent{0,4}/:hasParent[:hasGender :Female]").toString());
// PathElement element = PathParser.parsePathPattern(aPerson, ":hasParent[:hasGender :Female]{1,4}");
// assertEquals ("<http://inova8.com/intelligentgraph/path1/hasParent>[<http://inova8.com/intelligentgraph/path1/hasGender> <http://inova8.com/intelligentgraph/path1/Female> ]{1,4}" , element.toString());
// assertEquals ("{0=1, 1=2, 2=3, 3=4}",element.getIterations().toString());
// PathResults paths = aPerson.getPaths(":hasParent[:hasGender :Female]{1,4}");
// String pathString ="";
// for (Path path : paths) {
// pathString +=path.toString();
// }
// assertEquals("Path=[[http://inova8.com/intelligentgraph/path1/aPerson,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another3,INVERSE]\r\n"
// + "]\r\n"
// + "", pathString);
// assertEquals("Path=[[http://inova8.com/intelligentgraph/path1/aPerson,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another3,INVERSE]\r\n"
// + "]\r\n"
// + "", paths.toString());
// paths = aPerson.getPaths(":hasParent{1,4}/:hasParent[:hasGender :Female]");
// assertEquals("Path=[[http://inova8.com/intelligentgraph/path1/aPerson,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another3,INVERSE]\r\n"
// + "[http://inova8.com/intelligentgraph/path1/Another3,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another4,INVERSE]\r\n"
// + "[http://inova8.com/intelligentgraph/path1/Another4,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another5,INVERSE]\r\n"
// + "]\r\n"
// + "", paths.toString());
PathResults paths = aPerson.getPaths(":hasParent{0,4}/:hasParent[:hasGender :Female]");
assertEquals("Path=[[http://inova8.com/intelligentgraph/path1/aPerson,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another3,DIRECT]\r\n" + "]\r\n" + "Path=[[http://inova8.com/intelligentgraph/path1/aPerson,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another3,DIRECT]\r\n" + "[http://inova8.com/intelligentgraph/path1/Another3,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another4,DIRECT]\r\n" + "[http://inova8.com/intelligentgraph/path1/Another4,http://inova8.com/intelligentgraph/path1/hasParent,http://inova8.com/intelligentgraph/path1/Another5,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
} catch (Exception e) {
assertEquals("", e.getCause().getMessage());
fail();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_MMS_GetPath_Tests method test_2.
/**
* Test 2.
*/
@Test
@Order(2)
void test_2() {
try {
Thing _this = source.getThing("mms_ext:Sensitive_PII");
PathResults paths = _this.getPaths("^mms_ext:dataElementSensitivity/(^mms_ext:isDerivedFrom){1,5}/mms:context[eq sakila:dataset.customer_list]");
assertEquals("Path=[[http://in4mium.com/masterdatakg/schema/mms-ext#Sensitive_PII,http://in4mium.com/masterdatakg/schema/mms-ext#dataElementSensitivity,http://in4mium.com/masterdatakg/mms/id/sakila/column.customer.first_name,INVERSE]\r\n" + "[http://in4mium.com/masterdatakg/mms/id/sakila/column.customer.first_name,http://in4mium.com/masterdatakg/schema/mms-ext#isDerivedFrom,http://in4mium.com/masterdatakg/mms/id/sakila/column.customer_list.name,INVERSE]\r\n" + "[http://in4mium.com/masterdatakg/mms/id/sakila/column.customer_list.name,http://rdf.cdisc.org/mms#context,http://in4mium.com/masterdatakg/mms/id/sakila/dataset.customer_list,DIRECT]\r\n" + "]\r\n" + "Path=[[http://in4mium.com/masterdatakg/schema/mms-ext#Sensitive_PII,http://in4mium.com/masterdatakg/schema/mms-ext#dataElementSensitivity,http://in4mium.com/masterdatakg/mms/id/sakila/column.customer.last_name,INVERSE]\r\n" + "[http://in4mium.com/masterdatakg/mms/id/sakila/column.customer.last_name,http://in4mium.com/masterdatakg/schema/mms-ext#isDerivedFrom,http://in4mium.com/masterdatakg/mms/id/sakila/column.customer_list.name,INVERSE]\r\n" + "[http://in4mium.com/masterdatakg/mms/id/sakila/column.customer_list.name,http://rdf.cdisc.org/mms#context,http://in4mium.com/masterdatakg/mms/id/sakila/dataset.customer_list,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
use of com.inova8.intelligentgraph.results.PathResults in project com.inova8.intelligentgraph by peterjohnlawrence.
the class Local_MMS_GetPath_Tests method test_1.
/**
* Test 1.
*/
@Test
@Order(1)
void test_1() {
try {
Thing _this = source.getThing("sakila:column.customer_list.SID");
PathResults paths = _this.getPaths("mms:context");
assertEquals("Path=[[http://in4mium.com/masterdatakg/mms/id/sakila/column.customer_list.SID,http://rdf.cdisc.org/mms#context,http://in4mium.com/masterdatakg/mms/id/sakila/dataset.customer_list,DIRECT]\r\n" + "]\r\n" + "", paths.toString());
} catch (Exception e) {
assertEquals("", e.getMessage());
e.printStackTrace();
}
}
Aggregations