private OlsplPattern GetPatternByLabelOfProperty(OwlObjectProperty property, INode label) { var domain = property.Domain; var range = property.Range; var domainLocalName = domain.GetLocalName(); var rangeLocalName = range.GetLocalName(); var rule = $"{domainLocalName} {label} {rangeLocalName}"; var entity1 = new RdfEntity { //Type = domain.ToString(), TypeTerm = domainLocalName, Label = Var1, EntityIndex = 1, }; var entity2 = new RdfEntity { //Type = range.ToString(), TypeTerm = rangeLocalName, Label = Var2, EntityIndex = 2, }; var totalTriplet = new Triplet(domain, property, range, 1, 2); return(new OlsplPattern { Rule = rule, Entity1 = entity1, Entity2 = entity2, TotalTriplet = totalTriplet, Comment = "Generated via domain and ranges", }); }
public void test8() { OwlGraph ontology = new OwlGraph(); ontology.NameSpaces["xmlns:" + OwlNamespaceCollection.OwlNamespacePrefix] = OwlNamespaceCollection.OwlNamespace; ontology.NameSpaces["xmlns:" + OwlNamespaceCollection.RdfSchemaNamespacePrefix] = OwlNamespaceCollection.RdfSchemaNamespace; ontology.NameSpaces["xmlns:daml"] = "http://www.daml.org/2001/03/daml+oil#"; ontology.NameSpaces["xmlns:dc"] = "http://purl.org/dc/elements/1.1/"; ontology.NameSpaces["xmlns"] = "http://www.owl-ontologies.com/test.owl#"; ontology.NameSpaces["xml:base"] = "http://www.owl-ontologies.com/test.owl"; string baseUri = "http://www.owl-ontologies.com/test.owl#"; OwlClass testCls = new OwlClass(baseUri + "TestClass"); ontology.Nodes.Add(testCls); OwlRestriction testRestriction = new OwlRestriction("blankID:1"); ontology.Nodes.Add(testRestriction); OwlObjectProperty testProp = new OwlObjectProperty(baseUri + "testProp"); ontology.Nodes.Add(testProp); OwlEdge subClassOfRelation = new OwlEdge(OwlNamespaceCollection.RdfSchemaNamespace + "subClassOf"); subClassOfRelation.AttachParentNode(testCls); subClassOfRelation.AttachChildNode(testRestriction); ontology.Edges.Add(subClassOfRelation); OwlEdge onPropertyRelation = new OwlEdge(OwlNamespaceCollection.OwlNamespace + "onProperty"); onPropertyRelation.AttachParentNode(testRestriction); onPropertyRelation.AttachChildNode(testProp); ontology.Edges.Add(onPropertyRelation); OwlLiteral val = new OwlLiteral("1", null, "http://www.w3.org/2001/XMLSchema#int"); OwlEdge cardinalityRelation = new OwlEdge(OwlNamespaceCollection.OwlNamespace + "cardinality"); cardinalityRelation.AttachParentNode(testRestriction); cardinalityRelation.AttachChildNode(val); ontology.Edges.Add(cardinalityRelation); IOwlGenerator generator = new OwlXmlGenerator(); generator.GenerateOwl(ontology, @"c:\test.owl"); }