ontology 从多个 class 研究 EquivalentTo class

ontology research EquivalentTo class from multiple single classes

我正在玩披萨 ontology,我正在尝试获得我所理解的推断知识。 对于一些单个 类,我想使用它们获取其他 类 的名称。

确切地说,在比萨ontology中我们可以找到:

我正在尝试使用 MozzarellaToppingDeepPanBase 编写一个 SPARQL 请求,结果可能是 CheeseyPizza... 但我不知道该怎么做它,我不知道是否可以这样做。 (我在某处读到可以对个人进行推论,而不是对 类 ()...但 Protégé 似乎对 CheeseyPizza 进行推论)。

现在,我刚得到共同祖先列表(使用 Jena 示例):

showQuery(model, prefix
        + "SELECT ?o "
        + "WHERE { "
        + " pizza:MozzarellaTopping rdfs:subClassOf* ?o . "
        + " pizza:DeepPanBase rdfs:subClassOf* ?o . "
        + " FILTER ( ! isBlank(?o) ) " + "} "
        );

是否有 SPARQL 请求在不知道 ontology 结构的情况下从单个 类 获取推断的 类? (不知道ontology结构:老祖宗的要求,我只写了两个类的名字,却没给Food/Pizza结构...真想好好研究下在整个 ontology 中包含所有需要马苏里拉奶酪和 DeepPan 的东西)

谢谢!

编辑:

我忘了说我也在考虑使用推理器(我正在研究 Jena)。 但我不知道这是否是正确的制作方法。

我使用了很多文档,我想我终于找到了解决方案。 这不完全是我的预期,但现在就足够了。 主要思想:创建个体(concepts/classes 的实例),link 将它们组合在一起,并让推理者发现事物(推理)。

有用的文档(感谢 StakOverflow 的 links):

https://jena.apache.org/documentation/inference/#owl

http://jena.apache.org/documentation/ontology/#instances-or-individuals

http://jena.apache.org/documentation/ontology/index.html

首先,我的解决方案是什么:

  • 实例化基础模型(并加载披萨 ontology)
  • 实例化一个推理模型(并选择一个推理器)
  • 在基本模型中创建:多个个体和 properties/relations 他们之间
  • 检查模型的有效性,要求断言(在基本模型中)和

它正在工作。我可以创建一个人 "MozzarellaTopping"、一个人 "DeepPanBase" 和一个人 "Food"。我向 "Food" 添加了两个属性:hasBase 到单个 DeepPanBase,hasTopping 到单个 MozzarellaTopping。

下面是代码一步步解释(完整代码在最后):

从 pizza.owl.rdf

实例化并加载基础模型
    public static final String  SOURCE      = "./resources/";
    public static final String  PIZZA_NS    = "http://www.co-ode.org/ontologies/pizza/pizza.owl#";

    public void run()
    {
        // Prefix/Header for SPARQL requests
        final String prefix = "prefix pizza: <" + PIZZA_NS + ">\n"
                + "prefix rdfs: <" + RDFS.getURI() + ">\n" + "prefix owl: <"
                + OWL.getURI() + ">\n";
        // Prefix for classes, individuals, ... for every object
        final String NS = PIZZA_NS;

        System.out.println("CREATE THE BASE MODEL\n");
        // CREATE THE BASE MODEL
        OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
        base.read(SOURCE + "pizza.owl.rdf", "RDF/XML");

创建推断模型:

    System.out.println("CREATE THE REASONING MODEL USING THE BASE\n");
        // CREATE THE REASONING MODEL USING THE BASE
        OntModel inf = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, base);
        // OWL_MEM_MICRO_RULE_INF // It works + Very quick
        // OWL_MEM_MINI_RULE_INF // It works + Slow (40Mins) + 1,1Go RAM (Validity is slow)
        // OWL_MEM_RULE_INF // It works (mights loop if error) + VERY SLOW + 2,1 GO RAM (unfinished)
        // OWL_MEM_TRANS_INF // It works (SPARQL mights not work) + Ultra Speed / No inference

获取有用的 类 和 java 中的属性以用于将来的个体实例化:

        System.out.println("CREATE INDIVIDUALS FOR TESTING PURPOSE\n");
        // CREATE INDIVIDUALS FOR TESTING PURPOSE

        // Instantiate each useful Class
        OntClass ThingClass = base.getOntClass(NS + "owl:Thing");
        OntClass FoodClass = base.getOntClass(NS + "Food");
        OntClass IceCreamClass = base.getOntClass(NS + "IceCream");
        OntClass PizzaClass = base.getOntClass(NS + "Pizza");
        OntClass MozzaToppingClass = base.getOntClass(NS + "MozzarellaTopping");
        OntClass DeepPanBaseClass = base.getOntClass(NS + "DeepPanBase");

        // Instantiate each useful Property (relation)
        OntProperty hasIngredientProperty = base.createObjectProperty(NS + "hasIngredient");
        OntProperty hasBaseProperty = base.createObjectProperty(NS + "hasBase");
        OntProperty hasToppingProperty = base.createObjectProperty(NS + "hasTopping");

        // Instantiate each useful individual
        Individual MozzaTopping = base.createIndividual(NS + "MyMozzaTopping", MozzaToppingClass);
        Individual DeepPanBase = base.createIndividual(NS + "MyDeepPanBase", DeepPanBaseClass);

然后,我首先用两个同时 类(MozzarellaTopping 和 DeepPanBase)检查一个人...推理者看到了 CheeseyPizza,但有效性报告不起作用:

        /*
         * BEGINNING OF THE TESTS HERE
         */
        System.out.println("\nTEST VALIDITY BEFORE ADDING INDIVIDUALS\n");
        checkValidity(inf);

        // Instantiate testing individuals
        // MyPizza1 : individual with 2 classes simultaneously (Mozza & DeepPan)
        Individual MyPizza1 = base.createIndividual(NS + "MyPizza1", ThingClass);
        MyPizza1.setOntClass(MozzaToppingClass);
        MyPizza1.addOntClass(DeepPanBaseClass);

        System.out.println("\nTest MyPizza1\n");
        showAsserted(base, NS + "MyPizza1");
        showInferred(inf, NS + "MyPizza1");
        System.out.println("\nTest Validity of MyPizza1 : ");
        checkValidity(inf); // ERROR

        MyPizza1.remove();
        System.out.println("\nRemove MyPizza1, Validity should be OK now : ");
        checkValidity(inf); // OK

然后,我尝试了一个 "Food"(或 "Pizza")个人,我与之有关系 hasBase DeepPanBase,另一个关系 hasTopping MozzarellaTopping。它在工作,有效性检查中没有问题:

        // MyPizza2 : individual of class "Food", linked with Mozza & DeepPan
        Individual MyPizza2 = base.createIndividual(NS + "MyPizza2", FoodClass);
        MyPizza2.addProperty(hasBaseProperty, DeepPanBase);
        MyPizza2.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest MyPizza2\n");
        showAsserted(base, NS + "MyPizza2");
        showInferred(inf, NS + "MyPizza2");
        System.out.println("\nTest Validity of MyPizza2 : ");
        checkValidity(inf); // OK

        MyPizza2.remove();
        System.out.println("\nRemove MyPizza2, Validity should be OK now : ");
        checkValidity(inf); // OK

然后,我尝试了一个 DeepPanBase 个体,我给它一个 property/relation hasTopping MozzarellaTopping。推理者的行为也和你想象的一样:他说这是一个 CheeseyPizza,但是,有效性检查说它是错误的。

        // MyPizza3 : individual of class "DeepPanBase", linked with Mozza
        Individual MyPizza3 = base.createIndividual(NS + "MyPizza3", DeepPanBaseClass);
        MyPizza3.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest MyPizza3\n");
        showAsserted(base, NS + "MyPizza3");
        showInferred(inf, NS + "MyPizza3");
        System.out.println("\nTest Validity of MyPizza3 : ");
        checkValidity(inf); // ERROR

        MyPizza3.remove();
        System.out.println("\nRemove MyPizza3, Validity should be OK now : ");
        checkValidity(inf); // OK

最后,对冰淇淋个体(Food)进行了测试。我给它一个关系 hasBase DeepPanBase 和另一个关系 hasTopping MozzarellaTopping。推理者说这是 CheeseyPizza,有效性检查大声说这是错误的。

        // IceCream : individual of class "IceCream", linked with Moza & DeePan
        Individual MyIceCream = base.createIndividual(NS + "MyIceCream", IceCreamClass);
        MyIceCream.addProperty(hasBaseProperty, DeepPanBase);
        MyIceCream.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest IceCream\n");
        showAsserted(base, NS + "MyIceCream");
        showInferred(inf, NS + "MyIceCream");
        System.out.println("\nTest Validity of IceCream : ");
        checkValidity(inf);

有效性检查器是正确的。如果您查看什么是 Pizza,您会看到它是一个单独的 "Food",其中包含 "ingredients"/toppings,以及至少一个 PizzaBase...但它也不是 PizzaTopping,不是PizzaBase,而不是冰淇淋。 (这就是有效性检查哭泣的原因......如果我尝试将 PizzaTopping 放在 IceCream 上,那是不可能的......)


无论如何,正如我所承诺的,我在这里给出了完整的代码:

    /*
     * Example of usage of reasoner with Java. Everything is coming from Apache JENA
     * examples. I modified a lot of things for making my personal requests.
     * Fabrice Boissier
     */

    package Jena_Reasoner_Simple;

    import java.util.Date;
    import java.util.Iterator;

    import org.apache.jena.ontology.Individual;
    import org.apache.jena.ontology.OntClass;
    import org.apache.jena.ontology.OntModel;
    import org.apache.jena.ontology.OntModelSpec;
    import org.apache.jena.ontology.OntProperty;
    import org.apache.jena.rdf.model.ModelFactory;
    import org.apache.jena.rdf.model.Resource;
    import org.apache.jena.reasoner.ValidityReport;
    import org.apache.jena.vocabulary.OWL;
    import org.apache.jena.vocabulary.RDFS;

    public class Simple_Reasoner_StepByStep
    {
    public static void main(String[] args)
    {
        System.out.println("BEGIN : " + new Date());
        new Simple_Reasoner_StepByStep().run();
        System.out.println("END : " + new Date());
    }

    public static final String  SOURCE      = "./resources/";
    public static final String  PIZZA_NS    = "http://www.co-ode.org/ontologies/pizza/pizza.owl#";

    public void run()
    {
        // Prefix/Header for SPARQL requests
        final String prefix = "prefix pizza: <" + PIZZA_NS + ">\n"
                + "prefix rdfs: <" + RDFS.getURI() + ">\n" + "prefix owl: <"
                + OWL.getURI() + ">\n";
        // Prefix for classes, individuals, ... for every object
        final String NS = PIZZA_NS;

        System.out.println("CREATE THE BASE MODEL\n");
        // CREATE THE BASE MODEL
        OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
        base.read(SOURCE + "pizza.owl.rdf", "RDF/XML");

        System.out.println("CREATE THE REASONING MODEL USING THE BASE\n");
        // CREATE THE REASONING MODEL USING THE BASE
        OntModel inf = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, base);
        // OWL_MEM_MICRO_RULE_INF // It works + Very quick
        // OWL_MEM_MINI_RULE_INF // It works + Slow (40Mins) + 1,1Go RAM (Validity is slow)
        // OWL_MEM_RULE_INF // It works (mights loop if error) + VERY SLOW + 2,1 GO RAM (unfinished)
        // OWL_MEM_TRANS_INF // It works (SPARQL mights not work) + Ultra Speed / No inference

        System.out.println("CREATE INDIVIDUALS FOR TESTING PURPOSE\n");
        // CREATE INDIVIDUALS FOR TESTING PURPOSE

        // Instantiate each useful Class
        OntClass ThingClass = base.getOntClass(NS + "owl:Thing");
        OntClass FoodClass = base.getOntClass(NS + "Food");
        OntClass IceCreamClass = base.getOntClass(NS + "IceCream");
        OntClass PizzaClass = base.getOntClass(NS + "Pizza");
        OntClass MozzaToppingClass = base.getOntClass(NS + "MozzarellaTopping");
        OntClass DeepPanBaseClass = base.getOntClass(NS + "DeepPanBase");

        // Instantiate each useful Property (relation)
        OntProperty hasIngredientProperty = base.createObjectProperty(NS + "hasIngredient");
        OntProperty hasBaseProperty = base.createObjectProperty(NS + "hasBase");
        OntProperty hasToppingProperty = base.createObjectProperty(NS + "hasTopping");

        // Instantiate each useful individual
        Individual MozzaTopping = base.createIndividual(NS + "MyMozzaTopping", MozzaToppingClass);
        Individual DeepPanBase = base.createIndividual(NS + "MyDeepPanBase", DeepPanBaseClass);

        /*
         * BEGINNING OF THE TESTS HERE
         */
        System.out.println("\nTEST VALIDITY BEFORE ADDING INDIVIDUALS\n");
        checkValidity(inf);

        // Instantiate testing individuals
        // MyPizza1 : individual with 2 classes simultaneously (Mozza & DeepPan)
        Individual MyPizza1 = base.createIndividual(NS + "MyPizza1", ThingClass);
        MyPizza1.setOntClass(MozzaToppingClass);
        MyPizza1.addOntClass(DeepPanBaseClass);

        System.out.println("\nTest MyPizza1\n");
        showAsserted(base, NS + "MyPizza1");
        showInferred(inf, NS + "MyPizza1");
        System.out.println("\nTest Validity of MyPizza1 : ");
        checkValidity(inf); // ERROR

        MyPizza1.remove();
        System.out.println("\nRemove MyPizza1, Validity should be OK now : ");
        checkValidity(inf); // OK

        // MyPizza2 : individual of class "Food", linked with Mozza & DeepPan
        Individual MyPizza2 = base.createIndividual(NS + "MyPizza2", FoodClass);
        MyPizza2.addProperty(hasBaseProperty, DeepPanBase);
        MyPizza2.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest MyPizza2\n");
        showAsserted(base, NS + "MyPizza2");
        showInferred(inf, NS + "MyPizza2");
        System.out.println("\nTest Validity of MyPizza2 : ");
        checkValidity(inf); // OK

        MyPizza2.remove();
        System.out.println("\nRemove MyPizza2, Validity should be OK now : ");
        checkValidity(inf); // OK

        // MyPizza3 : individual of class "DeepPanBase", linked with Mozza
        Individual MyPizza3 = base.createIndividual(NS + "MyPizza3", DeepPanBaseClass);
        MyPizza3.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest MyPizza3\n");
        showAsserted(base, NS + "MyPizza3");
        showInferred(inf, NS + "MyPizza3");
        System.out.println("\nTest Validity of MyPizza3 : ");
        checkValidity(inf); // ERROR

        MyPizza3.remove();
        System.out.println("\nRemove MyPizza3, Validity should be OK now : ");
        checkValidity(inf); // OK

        // IceCream : individual of class "IceCream", linked with Moza & DeePan
        Individual MyIceCream = base.createIndividual(NS + "MyIceCream", IceCreamClass);
        MyIceCream.addProperty(hasBaseProperty, DeepPanBase);
        MyIceCream.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest IceCream\n");
        showAsserted(base, NS + "MyIceCream");
        showInferred(inf, NS + "MyIceCream");
        System.out.println("\nTest Validity of IceCream : ");
        checkValidity(inf);

        /*
         * END OF THE TESTS HERE
         */

        System.out.println("End Tests\n");
    }

    protected void showAsserted(OntModel m, String individualURI)
    {
        // list the asserted types
        Individual instance = m.getIndividual(individualURI); // BASE
        for (Iterator<Resource> i = instance.listRDFTypes(false); i.hasNext();)
        {
            System.out
                    .println(instance.getURI() + " is asserted in class " + i.next());
        }
    }

    protected void showInferred(OntModel m, String individualURI)
    {
        // list the inferred types
        Individual instance = m.getIndividual(individualURI); // INFERED
        for (Iterator<Resource> i = instance.listRDFTypes(false); i.hasNext();)
        {
            System.out.println(
                    instance.getURI() + " is inferred to be in class " + i.next());
        }
    }

    protected void checkValidity(OntModel inf)
    {
        ValidityReport validity = inf.validate();
        if (validity.isValid())
        {
            System.out.println("OK");
        }
        else
        {
            System.out.println("Conflicts");
            for (Iterator i = validity.getReports(); i.hasNext();)
            {
                System.out.println(" - " + i.next());
            }
        }
    }

}

要使代码在 Eclipse 或其他平台上运行,您首先需要将披萨本体文件 (pizza.owl.rdf) 放入名为 "resources" 的文件夹中,然后添加这些 JAR(在 Eclipse 中: 构建路径 -> 配置构建路径 -> 添加 JAR) :

  • commons-cli-1.3.jar
  • commons-lang3-3.4.jar
  • httpclient-4.5.2.jar
  • httpclient-cache-4.5.2.jar
  • httpcore-4.4.4.jar
  • jackson-annotations-2.7.0.jar
  • jackson-core-2.7.4.jar
  • jackson-databind-2.7.4.jar
  • jena-arq-3.3.0.jar
  • jena-base-3.3.0.jar
  • jena-core-3.3.0.jar
  • jena-iri-3.3.0.jar
  • jena-rdfconnection-3.3.0.jar
  • jena-shaded-guava-3.3.0.jar
  • jsonld-java-0.9.0.jar
  • libthrift-0.9.3.jar
  • log4j-1.2.17.jar
  • slf4j-api-1.7.21.jar
  • slf4j-log4j12-1.7.21.jar
  • xercesImpl-2.11.0.jar
  • xml-apis-1.4.01.jar

为了升级答案,这里有一段小代码,用于使用 Jena 加载模型,在其上启动推理器,添加个体(创建推理),并对基本模型和推理模型发出多个 SPARQL 请求让人们关注那里的模型 class :

package Jena_Reasoner_SPARQL;

import java.util.Date;
import java.util.Iterator;

import org.apache.jena.ontology.Individual;
import org.apache.jena.ontology.OntClass;
import org.apache.jena.ontology.OntModel;
import org.apache.jena.ontology.OntModelSpec;
import org.apache.jena.ontology.OntProperty;
import org.apache.jena.query.Query;
import org.apache.jena.query.QueryExecution;
import org.apache.jena.query.QueryExecutionFactory;
import org.apache.jena.query.QueryFactory;
import org.apache.jena.query.ResultSet;
import org.apache.jena.query.ResultSetFormatter;
import org.apache.jena.rdf.model.Model;
import org.apache.jena.rdf.model.ModelFactory;
import org.apache.jena.rdf.model.Resource;
import org.apache.jena.reasoner.ValidityReport;
import org.apache.jena.vocabulary.OWL;
import org.apache.jena.vocabulary.RDFS;

public class Simple_Reasoner_and_SPARQL_Request
{
    public static final String  SOURCE      = "./resources/";
    public static final String  PIZZA_NS    = "http://www.co-ode.org/ontologies/pizza/pizza.owl#";
    public static final String  prefix      = "prefix pizza: <" + PIZZA_NS + ">\n"
                                            + "prefix rdfs: <" + RDFS.getURI() + ">\n"
                                            + "prefix owl: <" + OWL.getURI() + ">\n";

    public static void main(String[] args)
    {
        System.out.println("BEGIN " + new Date());

        new Simple_Reasoner_and_SPARQL_Request().run();

        System.out.println("END " + new Date());
    }

    public void run()
    {
        String NS = PIZZA_NS;

        System.out.println("CREATE AND LOAD THE BASE MODEL");
        // CREATE AND LOAD THE BASE MODEL
        OntModel base = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM);
        base.read(SOURCE + "pizza.owl.rdf", "RDF/XML");

        System.out.println("CREATE THE REASONING MODEL USING THE BASE\n");
        // CREATE THE REASONING MODEL USING THE BASE
        OntModel inf = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM_MICRO_RULE_INF, base);
        // OWL_MEM_MICRO_RULE_INF // It works + Very quick
        // OWL_MEM_MINI_RULE_INF // It works + Slow (40Mins) + 1,1Go RAM (Validity is slow)
        // OWL_MEM_RULE_INF // It works (mights loop if error) + VERY SLOW + 2,1Go RAM (unfinished)
        // OWL_MEM_TRANS_INF // It works (SPARQL mights not work) + Ultra Speed / No inference

        System.out.println("CREATE INDIVIDUALS FOR TESTING PURPOSE\n");
        // CREATE INDIVIDUALS FOR TESTING PURPOSE

        // Instantiate each useful Class
        OntClass ThingClass = base.getOntClass(NS + "owl:Thing");
        OntClass FoodClass = base.getOntClass(NS + "Food");
        OntClass IceCreamClass = base.getOntClass(NS + "IceCream");
        OntClass PizzaClass = base.getOntClass(NS + "Pizza");
        OntClass MozzaToppingClass = base.getOntClass(NS + "MozzarellaTopping");
        OntClass DeepPanBaseClass = base.getOntClass(NS + "DeepPanBase");

        // Instantiate each useful Property (relation)
        OntProperty hasIngredientProperty = base.createObjectProperty(NS + "hasIngredient");
        OntProperty hasBaseProperty = base.createObjectProperty(NS + "hasBase");
        OntProperty hasToppingProperty = base.createObjectProperty(NS + "hasTopping");

        // Instantiate each useful individual
        Individual MozzaTopping = base.createIndividual(NS + "MyMozzaTopping", MozzaToppingClass);
        Individual DeepPanBase = base.createIndividual(NS + "MyDeepPanBase", DeepPanBaseClass);

        /*
         * BEGINNING OF THE TESTS HERE
         */
        System.out.println("\nTEST VALIDITY BEFORE ADDING INDIVIDUALS " + new Date() + "\n");
        checkValidity(inf);

        // Instantiate testing individuals
        // MyPizza1 : individual of class "Food", linked with Mozza & DeepPan
        Individual MyPizza1 = base.createIndividual(NS + "MyPizza1", FoodClass);
        MyPizza1.addProperty(hasBaseProperty, DeepPanBase);
        MyPizza1.addProperty(hasToppingProperty, MozzaTopping);

        System.out.println("\nTest MyPizza1 " + new Date() + "\n");
        showAsserted(base, NS + "MyPizza1");
        showInferred(inf, NS + "MyPizza1");
        System.out.println("\nTest Validity of MyPizza1 : " + new Date());
        checkValidity(inf); // OK

        // SPARQL Tests now
        System.out.println("\nSPARQL TESTS\n");
        printPrefix();

        // Research every Food
        System.out.println("\nResearch Food in Base model");
        showQuery(base,
                prefix + "SELECT ?individual " + "WHERE { "
                        + " ?individual a pizza:Food . "
                        + " FILTER ( ! isBlank(?individual) ) " + "} ");

        System.out.println("\nResearch Food in Inference model");
        showQuery(inf,
                prefix + "SELECT ?individual " + "WHERE { "
                        + " ?individual a pizza:Food . "
                        + " FILTER ( ! isBlank(?individual) ) " + "} ");

        // Research every CheeseyPizza
        System.out.println("\nResearch CheeseyPizza in Base model");
        showQuery(base,
                prefix + "SELECT ?individual " + "WHERE { "
                        + " ?individual a pizza:CheeseyPizza . "
                        + " FILTER ( ! isBlank(?individual) ) " + "} ");

        System.out.println("\nResearch CheeseyPizza in Inference model");
        showQuery(inf,
                prefix + "SELECT ?individual " + "WHERE { "
                        + " ?individual a pizza:CheeseyPizza . "
                        + " FILTER ( ! isBlank(?individual) ) " + "} ");

        /*
         * END OF THE TESTS HERE
         */

        System.out.println("End Tests\n");
    }

    protected void showAsserted(OntModel m, String individualURI)
    {
        // list the asserted types
        Individual instance = m.getIndividual(individualURI); // BASE
        for (Iterator<Resource> i = instance.listRDFTypes(false); i.hasNext();)
        {
            System.out
                    .println(instance.getURI() + " is asserted in class " + i.next());
        }
    }

    protected void showInferred(OntModel m, String individualURI)
    {
        // list the inferred types
        Individual instance = m.getIndividual(individualURI); // INFERED
        for (Iterator<Resource> i = instance.listRDFTypes(false); i.hasNext();)
        {
            System.out.println(
                    instance.getURI() + " is inferred to be in class " + i.next());
        }
    }

    protected void checkValidity(OntModel inf)
    {
        ValidityReport validity = inf.validate();
        if (validity.isValid())
        {
            System.out.println("OK");
        }
        else
        {
            System.out.println("Conflicts");
            for (Iterator i = validity.getReports(); i.hasNext();)
            {
                System.out.println(" - " + i.next());
            }
        }
    }

    protected void printPrefix()
    {
        System.out.println(prefix);
    }

    protected void showQuery(Model m, String q)
    {
        Query query = QueryFactory.create(q);
        QueryExecution qexec = QueryExecutionFactory.create(query, m);
        try
        {
            ResultSet results = qexec.execSelect();
            ResultSetFormatter.out(results, m);
        }
        finally
        {
            qexec.close();
        }

    }
}