[Gate-users] Fwd: Populating Ontologies in Java using Gate Application Pipeline

Dávid Völgyes david.volgyes at gmail.com
Mon Oct 5 14:24:35 CEST 2015


Dear Lida,

There are many GATE applications, including these two:
https://gate.ac.uk/    (General architecture for text engineering)
http://www.opengatecollaboration.org/   (Tomography simulator)

The first one you are looking for.
But this e-mail list belongs to the second one.

I think you need this email list: https://gate.ac.uk/mail/

Best,
   David

On Mon, Oct 5, 2015 at 2:07 PM, Lida Ghahremanlou <
lida.ghahremanlou at gmail.com> wrote:

> ---------- Forwarded message ----------
> From: "Lida Ghahremanlou" <lida.ghahremanlou at gmail.com>
> Date: 5 Oct 2015 7:43 pm
> Subject: Populating Ontologies in Java using Gate Application Pipeline
> To: <gate-users-request at lists.opengatecollaboration.org>
> Cc:
>
> Hi,
>
> I have two queries (Question A and Question B) for populating Ontologies
> using Gate application in Java. Here is the steps that I have successfully
> implemented in my java program:
>
>
>    1. I created a customized pipeline with mylist.def and my own
>    gazetteers, which successfully annotated the sample corpus ( a list of
>    tweets) loaded in GUI.
>    2.  I then extracted the application pipeline and used it in the
>    BatchGate program (given from this code) which also successfully annotated
>    and extract the buildin xml file.
>    3. Next, I wanted to populate my ontology using the annotation text,
>    following the code explain in the jape rule and 46 and 47 slides(
>    https://gate.ac.uk/wiki/TrainingCourseJune2012/track-2/module-6-code.html).
>
>    4. However, my java program can read and populate and write the
>    ontology file successfully but, the program does not exit. Tracing the
>    code  gave me the impression that loading the existing ontology causes this
>    issue:
>    5.
>
>    // init GATE and load plugin as before...
>
>    URL owl = new File("ontology.owl").toURI().toURL();
>    FeatureMap params = Factory.newFeatureMap();
>    params.put("rdfXmlURL", owl);
>    Ontology theOntology = (Ontology)Factory.createResource(
>        "gate.creole.ontology.impl.sesame.OWLIMOntology",
>        params);
>
>    6.
>
>    *Question A:* How can I solve this? I read something about Ontology URL mappings.Can anyone give me more details?
>
>    7. After that I pass this problem, I want to populate my ontology per
>    annotation. Each annotation is a class. Meaning that I annotated each
>    tweets as a sentence and then within each sentence, I want the other
>    annotations. e.g.
>
>
> *Tweet: #Ausopen Rafa won Rajor! Such a match*
>
>
> *<Sentence> AusOpen <Player> Rafa </Player> won  <Player>Rajor</Player> !
> Such a match </Sentence> *
> I have written the code from the Jape example, however I still cannot get
> the annotation within each sentence tag.
> *Question B: How I can get the annotation within another annotation to
> populate my ontology? *
>
>    /find the annotation matched by LHS
>   //we know the annotation set returned
>   //will always contain a single annotation
>   Annotation mentionAnn = mentionAnnots.iterator().next();
>   //System.err.println("Annotation lenght : " + mentionAnn.lenght);
>
>   //find the class of the mention
>   String className = (String)mentionAnn.getFeatures().
>     get(gate.creole.ANNIEConstants.LOOKUP_CLASS_FEATURE_NAME);
>   // should normalize class name and avoid invalid class names here!
>   //OClass aClass =
> ontology.getOClass(ontology.createOURIForName(className));
>   OClass aClass = ontology.getOClass(ontology.createOURIForName("Player"));
>   if(aClass == null) {
>     System.err.println("Error class \"" + className + "\" does not
> exist!");
>     return;
>   }
>
>   //find the text covered by the annotation
>   String theMentionText = gate.Utils.stringFor(doc, mentionAnn);
>
>   // when creating a URI from text that came from a document you must take
> care
>   // to ensure that the name does not contain any characters that are
> illegal
>   // in a URI.  The following method does this nicely for English but you
> may
>   // want to do your own normalization instead if you have non-English
> text.
>   String mentionName = OUtils.toResourceName(theMentionText);
>
>   // get the property to store mention texts for mention instances
>   DatatypeProperty prop =
>
> ontology.getDatatypeProperty(ontology.createOURIForName("mentionText"));
>
>   OURI mentionURI = ontology.createOURIForName(mentionName);
>   // if that mention instance does not already exist, add it
>   if (!ontology.containsOInstance(mentionURI)) {
>     OInstance inst = ontology.addOInstance(mentionURI, aClass);
>
> Thank you for your help!
>
> _______________________________________________
> Gate-users mailing list
> Gate-users at lists.opengatecollaboration.org
> http://lists.opengatecollaboration.org/mailman/listinfo/gate-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opengatecollaboration.org/mailman/private/gate-users/attachments/20151005/90b303dd/attachment-0001.html>


More information about the Gate-users mailing list