Ontology (Onto Root Gazetteer)


albertosoki505@...
 

My text/json

{

    "openapi": "3.0.0",

    "info": {

        "title": "Sea tracking ",

        "description": "Sea tracking is an API that provides location data for a particular cargo such     as the current position of the cargo, departure and arrival seaports and the route between seaports",

        "termsOfService": "http://127.0.0.1:8000/api/terms",

        "contact": {

            "name": "API Support",

            "url": "http://127.0.0.1:8000/api/support",

            "email": "support@..."

        },

        "license": {

            "name": "Apache 2.0",

            "url": "http://www.apache.org/licenses/LICENSE-2.0.html"

        },

        "version": "1.0.0"

    },

  }

_____________________________________________________________________________

I annotated the above text using Onto Root Gazetteer and an ontology and got the following result:



Guys, how do I get for example all properties and values of the info class using a Jape Rule?

 

I tried doing the following, but it didn't work:

 

Phase:ontoMatcing

Input: Lookup Token Sentence 

Options: control = appelt

 

Rule: populationDescription

( {Sentence contains {Lookup.URI == "http://www.w3.org/ns/shacl#Info"}}|

   ({Sentence contains {Lookup.URI == "http://www.intelligence.tuc.gr/ns/open-api#description"}}):sentences

)

-->

:sentences.getSentences = {rule= "populationDescription"}


And then the idea is to populate the ontology with property values using the following Jape Rule :

 

Rule: FindEntities

({Mention}):mention

-->

:mention{

  //find the annotation matched by LHS

  //we know the annotation set returned

  //will always contain a single annotation

  Annotation mentionAnn = mentionAnnots.iterator().next();

 

  //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));

  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);

    // add the actual mention text to the instance

    try {

      inst.addDatatypePropertyValue(prop,

        new Literal(theMentionText, OConstants.ENGLISH));

    }

    catch(InvalidValueException e) {

      throw new JapeException(e);

    }

  }

}