コード例 #1
0
        public void OntologyClasses()
        {
            OntologyGraph g = new OntologyGraph();

            g.LoadFromFile("ontology.ttl");

            //Check Class Counts
            Assert.AreEqual(1, g.RdfClasses.Count());
            Assert.AreEqual(1, g.OwlClasses.Count());
            Assert.AreEqual(2, g.AllClasses.Count());
        }
コード例 #2
0
        public void OntologyClasses()
        {
            OntologyGraph g = new OntologyGraph();

            g.LoadFromFile("resources\\ontology.ttl");

            //Check Class Counts
            Assert.Single(g.RdfClasses);
            Assert.Single(g.OwlClasses);
            Assert.Equal(2, g.AllClasses.Count());
        }
コード例 #3
0
        public void OntologyProperties()
        {
            OntologyGraph g = new OntologyGraph();

            g.LoadFromFile("ontology.ttl");

            //Check Property Counts
            Assert.AreEqual(1, g.RdfProperties.Count());
            Assert.AreEqual(1, g.OwlAnnotationProperties.Count());
            Assert.AreEqual(1, g.OwlDatatypeProperties.Count());
            Assert.AreEqual(1, g.OwlObjectProperties.Count());
            Assert.AreEqual(3, g.OwlProperties.Count());
            Assert.AreEqual(4, g.AllProperties.Count());
        }
コード例 #4
0
        public void OntologyClassCount1()
        {
            OntologyGraph g = new OntologyGraph();

            g.LoadFromFile("swrc.owl");
            Assert.IsFalse(g.IsEmpty);

            //Count classes, raw and distinct count should be same
            int count         = g.OwlClasses.Count();
            int distinctCount = g.OwlClasses.Select(c => c.Resource).Distinct().Count();

            Console.WriteLine("Count = " + count);
            Console.WriteLine("Distinct Count = " + distinctCount);

            Assert.IsTrue(count == distinctCount, "Expected raw and distinct counts to be the same, got " + count + " and " + distinctCount);
        }
コード例 #5
0
ファイル: OntologyTests.cs プロジェクト: charbull/dotnetrdf
        public void OntologyClassBasic()
        {
            //Load Test Data
            Console.WriteLine("Loading in the standard test data InferenceTest.ttl");
            OntologyGraph g = new OntologyGraph();

            g.LoadFromFile("resources\\InferenceTest.ttl");

            //Get the class of Ground Vehicles
            OntologyClass groundVehicle = g.CreateOntologyClass(new Uri("http://example.org/vehicles/GroundVehicle"));

            Console.WriteLine("Got the class of Ground Vehicles");
            foreach (OntologyClass c in groundVehicle.SuperClasses)
            {
                Console.WriteLine("Super Class: " + c.Resource.ToString());
            }
            foreach (OntologyClass c in groundVehicle.SubClasses)
            {
                Console.WriteLine("Sub Class: " + c.Resource.ToString());
            }
            Console.WriteLine();

            //Get the class of Cars
            OntologyClass car = g.CreateOntologyClass(new Uri("http://example.org/vehicles/Car"));

            Console.WriteLine("Got the class of Cars");
            foreach (OntologyClass c in car.SuperClasses)
            {
                Console.WriteLine("Super Class: " + c.Resource.ToString());
            }
            foreach (OntologyClass c in car.SubClasses)
            {
                Console.WriteLine("Sub Class: " + c.Resource.ToString());
            }
            foreach (OntologyResource r in car.Instances)
            {
                Console.WriteLine("Instance: " + r.Resource.ToString());
            }
        }
コード例 #6
0
        public void OntologyClassCount2()
        {
            OntologyGraph g = new OntologyGraph();

            g.LoadFromFile("swrc.owl");
            Assert.IsFalse(g.IsEmpty);

            OntologyClass   classOfClasses = g.CreateOntologyClass(g.CreateUriNode("owl:Class"));
            int             count          = 0;
            HashSet <INode> resources      = new HashSet <INode>();

            //This iterates over the things that are a class
            foreach (OntologyResource c in classOfClasses.Instances)
            {
                count++;
                resources.Add(c.Resource);
            }

            Console.WriteLine("Count = " + count);
            Console.WriteLine("Distinct Count = " + resources.Count);

            Assert.AreEqual(resources.Count, count);
        }
コード例 #7
0
 public OntologyGraph LoadOntology(string filePath)
 {
     var graph = new OntologyGraph();
     graph.LoadFromFile(filePath);
     return graph;
 }