[protege-owl] Unicode problem in Script tab

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

[protege-owl] Unicode problem in Script tab

rtmyers
I'm using the Script tab to walk my ontology. Basically this works fine. The
problem is that some labels have non-Latin characters, and when I attempt to
write those to a file those characters are corrupted. This happens when using
both Python and Ruby. Here's an example of what I'm doing:

label = cls.getLabels()[0]
open("my.file","w").write(label)

The characters in question get output correctly to the console, so I can copy-
and-paste from there, but that's a bit cumbersome.

According to the Python docs, there's a module called codecs which can be used
to open a file like this:

codecs.open("my.file", encoding="urf8")

but I'm informed that Jython cannot find any module named codecs.

Any ideas?

--
Bob Myersr


-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

[protege-owl] Re: Unicode problem in Script tab

Olivier Dameron
On Wed, 5 Jul 2006 16:47:11 +0000 (UTC), Bob Myers <[hidden email]> wrote:

> fine. The problem is that some labels have non-Latin characters, and
> when I attempt to write those to a file those characters are
> corrupted. This happens when using both Python and Ruby. Here's an
> example of what I'm doing:
>
> label = cls.getLabels()[0]
> open("my.file","w").write(label)
>
> The characters in question get output correctly to the console, so I
> can copy- and-paste from there, but that's a bit cumbersome.

Well, that is something I never tried before.

It looks like there is a unicode(...) function
e.g. unicode('hello','iso-8859-1')
and an encode(...) function
e.g. mystring.encode('utf8')

source: http://www.reportlab.com/i18n/python_unicode_tutorial.html

I couldn't manage to get it to work here, though (it complains that
there is no codec search functions registered). The doc says that it
has been incorporated into python as of version 1.6, so it could be
in jython as well (hoping that it is indeed in the subset of python
implemented in jython).
Maybe it is just a matter of configuring the
pythonpath or something, but the problem may as well come from the java
code that feeds the text lines to the script engine. I wil ltry to look
at this.

> Any ideas?

Well, an engineer's idea would be to use the 'recode' program (on any
decent *nix) to perform the conversions on the files before you parse
them in the protege script console :-)

Olivier
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

[protege-owl] Import From Oracle

Kostas Vavliakis
Hello,
I have created an ontology and I want to create instances for the classes
based on a relational database. I tried DataGenie plug-in but it creates new
classes for every table of the db, while I want to create instances for the
classes I have already created. Is there any other way to automatically
create instances from a database?

Thank you in advance,
Kostas.

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

[protege-owl] Re: Import From Oracle

Bellave Jayaram
You have two main options:

1. Write a Java program to do it
        a. As a standalone application
        b. As a Protégé plugin
   See http://protege.stanford.edu/doc/dev.html

2. Use the ScriptTab plugin - see
http://protege.cim3.net/cgi-bin/wiki.pl?ProtegeScriptTab

Jayaram

> -----Original Message-----
> From: [hidden email]
> [mailto:[hidden email]] On Behalf Of
> Vavliakis Kostas
> Sent: Wednesday, July 05, 2006 3:35 PM
> To: [hidden email]
> Subject: [protege-owl] Import From Oracle
>
> Hello,
> I have created an ontology and I want to create instances for
> the classes based on a relational database. I tried DataGenie
> plug-in but it creates new classes for every table of the db,
> while I want to create instances for the classes I have
> already created. Is there any other way to automatically
> create instances from a database?
>
> Thank you in advance,
> Kostas.
>
> --------------------------------------------------------------
> -----------
> To unsubscribe go to
> http://protege.stanford.edu/community/subscribe.html
>

-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html

Reply | Threaded
Open this post in threaded view
|

[protege-owl] Re: Unicode problem in Script tab

Olivier Dameron
In reply to this post by rtmyers
On Wed, 5 Jul 2006 16:47:11 +0000 (UTC), Bob Myers <[hidden email]> wrote:

> I'm using the Script tab to walk my ontology. Basically this works
> fine. The problem is that some labels have non-Latin characters, and
> when I attempt to write those to a file those characters are
> corrupted. This happens when using both Python and Ruby. Here's an
> example of what I'm doing:
>
> label = cls.getLabels()[0]
> open("my.file","w").write(label)
>
> The characters in question get output correctly to the console, so I
> can copy- and-paste from there, but that's a bit cumbersome.
>
> According to the Python docs, there's a module called codecs which
> can be used to open a file like this:
>
> codecs.open("my.file", encoding="urf8")
>
> but I'm informed that Jython cannot find any module named codecs.

Hello Bob,
   I was thinking about your problem and just wondered if there is not
an alternative solution.
   One of the advantages of the script plugin is that it relies on java
implementations of some script languages... therefore, from the script
console, you theoretically have access to the functions provided by the
script language + all the default java functions.
   Have you tried the unicode support the the java.lang.Character class?

Hope this helps
Olivier
-------------------------------------------------------------------------
To unsubscribe go to http://protege.stanford.edu/community/subscribe.html