Re: Importing several ontologies from stream
Tania Tudorache <tudorache <at> stanford.edu>
2008-04-30 23:38:13 GMT
Hi Ralf,
I have made the setErrorLevel public. The parser code in the next beta
release will be much different than the one in the current release.
Please remind me to post an example for importing from streams after we
release the new beta.
Thanks,
Tania
Ralf Weinand wrote:
> Hi Tania,
>
> thanks a lot for this hint!
> No it works without temp files and repositories! Great!
>
> The methods
> - createARPInvokation(final Reader reader, final String uri)
> - setErrorLevel(ARP arp)
> are not public so I had to copy them into my class.
> maybe you could make them public?
>
> Anyway, thanks heaps again!
>
> Ralf
>
>
>
>
> On Thu, Apr 24, 2008 at 1:51 AM, Tania Tudorache <tudorache <at> stanford.edu> wrote:
>
>> Ralf,
>>
>> You can do the import from a stream, but not in a straightforward way. Look
>> at the method:
>>
>> public static void addImport(JenaOWLModel owlModel,
>> URI ontologyName,
>> String prefixForDefaultNamespace)
>>
>> from ProtegeOWLParser.java (I've attached the class code). You can
>> basically copy that code in your own method. Make sure that you also add the
>> import statement to the importing ontology (see javadoc comment) after you
>> do the import. Probably you can get rid of the repository code in the
>> method.
>>
>> Tania
>>
>>
>>
>>
>>
>> Ralf Weinand wrote:
>>
>>
>>> Hi Tania,
>>>
>>> thanks for the hint.
>>> I don´t think, that this method is what I need, but I did see another
>>> (undocumented) method in RepositoryUtil:
>>>
>>>
>> http://protege.stanford.edu/download/prerelease_javadoc_owl/edu/stanford/smi/protegex/owl/repository/util/RepositoryUtil.html#createImportLocalCopy(edu.stanford.smi.protegex.owl.model.OWLModel,%20java.net.URI,%20java.io.File)
>>
>>> Can you tell me what it does?
>>>
>>> Again my problem: i don´t have these ontologies stored physically.
>>> I receive them as org.w3c.dom.Element objects so I do not have a
>>> physical location (URL).
>>> They are just in memory, but I have to import them into one common
>>> knowledgebase.
>>> That´s why I have to write them temporarily to files and them load the
>>> first one and import the others.
>>> I´m looking for a better approach.
>>>
>>> Thanks!
>>> Ralf
>>>
>>>
>>>
>>> On Wed, Apr 23, 2008 at 3:36 AM, Tania Tudorache <tudorache <at> stanford.edu>
>>>
>> wrote:
>>
>>>
>>>> Ralf,
>>>>
>>>> There was recently a post that might be relevant. See this thread [1].
>>>>
>>>> There is a new utility method,
>>>> RepositoryUtil.loadProjectRepositoriesFromURI(...) that may help. See
>>>> also the Javadoc of this method. You can add as a project repository a
>>>> URL and then do the import with the ontology name (not ontology URL).
>>>> The parser will look at the repositories and get an input stream from
>>>> the repository URL.
>>>>
>>>> I haven't tested this yet, but I think it should work.
>>>>
>>>> Tania
>>>>
>>>> [1]:
>>>>
>> http://article.gmane.org/gmane.comp.misc.ontology.protege.owl/24368
>>
>>>>
>>>>
>>>> Ralf Weinand wrote:
>>>> > Hi,
>>>> >
>>>> > I am writing a program that receives several ontologies (as strings -
>>>> > or, to be more precise - as RDF/XML serializations).
>>>> > All of these ontologies have to be imported into one common knowledge
>>>> > base to perform some reasoning (also using Jess for SWRL rules).
>>>> > Now I am facing a problem. The first serialization I can simply load
>>>>
>> via
>>
>>>> >
>>>> > dataflowModel =
>>>> > ProtegeOWL.createJenaOWLModelFromReader(new StringReader(ontology1));
>>>> >
>>>> > But for the rest of the ontologies I have to first write each one
>>>>
>> into
>>
>>>> > a temporary file, take the URI and use this URI
>>>> > to import the ontology via
>>>> >
>>>> > ImportHelper importHelper = new
>>>>
>> ImportHelper(dataflowModel);
>>
>>>> >
>>>> > for (int i = 3; i < aArgs.size(); i++)
>>>> > {
>>>> > File sourceModelFile =
>>>> > SemanticUtils.writeOntologyToTempFile(aArgs.get(i));
>>>> > importHelper.addImport(sourceModelFile.toURI());
>>>> > }
>>>> >
>>>> > importHelper.importOntologies();
>>>> >
>>>> > Isn´t there a mode convenient method to do this?
>>>> > I don´t like the idea of using temp-files.
>>>> >
>>>> > Also, I am facing some problems with this method (some dependencies
>>>> > regarding the order in which I do the imports).
>>>> > Do I have to use a repository manager somehow?
>>>> > Any recommendations?
>>>> >
>>>> > Cheers,
>>>> > Ralf
>>>> > _______________________________________________
>>>> > protege-owl mailing list
>>>> > protege-owl <at> lists.stanford.edu
>>>> > https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>> >
>>>> > Instructions for unsubscribing:
>>>>
>> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>>> >
>>>> >
>>>>
>>>> _______________________________________________
>>>> protege-owl mailing list
>>>> protege-owl <at> lists.stanford.edu
>>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>>
>>>> Instructions for unsubscribing:
>>>>
>> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>>>
>>>>
>>> _______________________________________________
>>> protege-owl mailing list
>>> protege-owl <at> lists.stanford.edu
>>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>>
>>> Instructions for unsubscribing:
>>>
>> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>>
>> _______________________________________________
>> protege-owl mailing list
>> protege-owl <at> lists.stanford.edu
>> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>>
>> Instructions for unsubscribing:
>> http://protege.stanford.edu/doc/faq.html#01a.03
>>
>>
>>
> _______________________________________________
> protege-owl mailing list
> protege-owl <at> lists.stanford.edu
> https://mailman.stanford.edu/mailman/listinfo/protege-owl
>
> Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03
>
>
_______________________________________________
protege-owl mailing list
protege-owl <at> lists.stanford.edu
https://mailman.stanford.edu/mailman/listinfo/protege-owl
Instructions for unsubscribing: http://protege.stanford.edu/doc/faq.html#01a.03