public void test6(string file) { IOwlParser parser = new OwlXmlParser(); IOwlGraph graph = parser.ParseOwl(file); IOwlGenerator generator = new OwlXmlGenerator(); generator.GenerateOwl(graph, @"c:\travelnew.owl"); }
public void test5(string file) { IOwlParser parser = new OwlXmlParser(); IOwlGraph graph = parser.ParseOwl(file); string baseUri = "http://www.owl-ontologies.com/travel.owl#"; OwlClass hotelNode = (OwlClass)graph.Nodes["http://www.owl-ontologies.com/travel.owl#LuxuryHotel"]; OwlIndividual newHotel = new OwlIndividual(baseUri + "PellensPalace", hotelNode); graph.Nodes.Add(newHotel); IOwlGenerator generator = new OwlXmlGenerator(); generator.GenerateOwl(graph, @"c:\travelnew.owl"); }
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"); }
public void test2() { 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:domain"] = "http://www.owl-ontologies.com/domain.owl#"; 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#"; string altUri = "http://www.owl-ontologies.com/domain.owl#"; OwlOntology o = new OwlOntology(baseUri + "testOntology"); ontology.Nodes.Add(o); OwlClass a = new OwlClass(altUri + "ClassA"); //ontology.Nodes.Add(a); OwlIndividual inst = new OwlIndividual(baseUri + "Car", a); ontology.Nodes.Add(inst); //OwlClass b = new OwlClass(baseUri + "ClassB"); //ontology.Nodes.Add(b); // OwlClass concept = new OwlClass(altUri+node.Type); //Create a concept node // // OwlIndividual instance = new OwlIndividual(baseUri + node.ID, concept); // create an instance node as individual of concept node // _description.Nodes.Add(instance); //OwlEdge relation = new OwlEdge(OwlNamespaceCollection.RdfSchemaNamespace + "subClassOf"); //relation.AttachParentNode(a); //relation.AttachChildNode(b); //ontology.Edges.Add(relation); IOwlGenerator generator = new OwlXmlGenerator(); generator.GenerateOwl(ontology, @"c:\example2.owl"); }
public void test10(string file) { IOwlParser parser = new OwlXmlParser(); IOwlGraph graph = parser.ParseOwl(file); IOwlGenerator generator = new OwlXmlGenerator(); ArrayList errors = ((OwlGenerator)generator).Errors; ArrayList warnings = ((OwlGenerator)generator).Warnings; ArrayList messages = ((OwlGenerator)generator).Messages; FileStream info = new FileStream("c:/info.txt", FileMode.OpenOrCreate); StreamWriter sw = new StreamWriter(info); sw.AutoFlush = true; generator.GenerateOwl(graph, @"c:\test.owl"); foreach (string msg in messages) { sw.WriteLine(msg); } }
public void test1(string file) { IOwlParser parser = new OwlXmlParser(); IOwlGraph graph = parser.ParseOwl(file); ArrayList errors = ((OwlParser)parser).Errors; ArrayList warnings = ((OwlParser)parser).Warnings; ArrayList messages = ((OwlParser)parser).Messages; //FileStream info = new FileStream("c:/info.txt", FileMode.OpenOrCreate); //StreamWriter sw = new StreamWriter(info); //sw.AutoFlush = true; //IOwlGenerator generator = new OwlXmlGenerator(); //generator.GenerateOwl(graph, @"c:\example1.owl"); //info = new FileStream("C:/generated.txt", FileMode.OpenOrCreate); //sw = new StreamWriter(info); //sw.AutoFlush = true; // foreach(string msg in messages) // { // sw.WriteLine(msg); // } // // Console.WriteLine("Graph parsed successfully with {0} errors and {1} warnings\n\n",errors.Count,warnings.Count); // // foreach(string err in errors) // { // Console.WriteLine("Error: "+err); // } // // foreach(string war in warnings) // { // Console.WriteLine("Warning: "+war); // } // // Console.WriteLine("The graph contains {0} node(s) and {1} edge(s).", graph.Nodes.Count, graph.Edges.Count); string baseuri = graph.NameSpaces["xmlns"]; Console.WriteLine("The basuri is " + baseuri); OwlClass owlAnnotation = new OwlClass(baseuri + "Annotation"); //Create a parent (Annotation) node to relate to OwlGraph newGraph = new OwlGraph(); newGraph.NameSpaces["xmlns:" + OwlNamespaceCollection.OwlNamespacePrefix] = OwlNamespaceCollection.OwlNamespace; newGraph.NameSpaces["xmlns:" + OwlNamespaceCollection.RdfSchemaNamespacePrefix] = OwlNamespaceCollection.RdfSchemaNamespace; newGraph.NameSpaces["xmlns:daml"] = "http://www.daml.org/2001/03/daml+oil#"; newGraph.NameSpaces["xmlns:domain"] = "http://www.owl-ontologies.com/domain.owl#"; newGraph.NameSpaces["xmlns:dc"] = "http://purl.org/dc/elements/1.1/"; newGraph.NameSpaces["xmlns"] = "http://www.owl-ontologies.com/test.owl#"; newGraph.NameSpaces["xml:base"] = "http://www.owl-ontologies.com/test.owl"; newGraph.NameSpaces["xmlns:meta"] = baseuri; string newUri = "http://www.owl-ontologies.com/test.owl#"; OwlIndividual pp = new OwlIndividual(newUri + "Test", owlAnnotation); //Create the annotation newGraph.Nodes.Add(pp); IOwlGenerator generator = new OwlXmlGenerator(); generator.GenerateOwl(newGraph, @"c:\example2.owl"); }