2

基本的に、.txt の新しい行にそれぞれ数千の名前の大きなファイルがあります。Protege を使用してオントロジーを構築していますが、これらの名前を個人としてオントロジーの概念「人」に挿入するためのより迅速な方法が必要です。プロテジの追加ボタンをクリックし、各名前を入力/コピーして「人」の概念に追加すると、プロテジまたはOWL APIを使用してこれを行うことができますが、時間がかかります。

提案をありがとう。

4

1 に答える 1

2

OWL API を使用している場合は、ドキュメントで提供されている例に、これを行う方法の例があります。

public void shouldAddClassAssertion() throws OWLOntologyCreationException,
        OWLOntologyStorageException {
    // For more information on classes and instances see the OWL 2 Primer
    // http://www.w3.org/TR/2009/REC-owl2-primer-20091027/#Classes_and_Instances
    // In order to say that an individual is an instance of a class (in an
    // ontology), we can add a ClassAssertion to the ontology. For example,
    // suppose we wanted to specify that :Mary is an instance of the class
    // :Person. First we need to obtain the individual :Mary and the class
    // :Person Create an ontology manager to work with
    OWLOntologyManager manager = OWLManager.createOWLOntologyManager();
    OWLDataFactory dataFactory = manager.getOWLDataFactory();
    // The IRIs used here are taken from the OWL 2 Primer
    String base = "http://example.com/owl/families/";
    PrefixManager pm = new DefaultPrefixManager(base);
    // Get the reference to the :Person class (the full IRI will be
    // <http://example.com/owl/families/Person>)
    OWLClass person = dataFactory.getOWLClass(":Person", pm);
    // Get the reference to the :Mary class (the full IRI will be
    // <http://example.com/owl/families/Mary>)
    OWLNamedIndividual mary = dataFactory
            .getOWLNamedIndividual(":Mary", pm);
    // Now create a ClassAssertion to specify that :Mary is an instance of
    // :Person
    OWLClassAssertionAxiom classAssertion = dataFactory
            .getOWLClassAssertionAxiom(person, mary);
    // We need to add the class assertion to the ontology that we want
    // specify that :Mary is a :Person
    OWLOntology ontology = manager.createOntology(IRI.create(base));
    // Add the class assertion
    manager.addAxiom(ontology, classAssertion);
    // Dump the ontology to stdout
    manager.saveOntology(ontology, new StreamDocumentTarget(
            new ByteArrayOutputStream()));
}
于 2014-03-26T07:17:42.623 に答える