org.apache.jena.ontology.OntProperty Java Examples

The following examples show how to use org.apache.jena.ontology.OntProperty. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ModelStorage.java    From FCA-Map with GNU General Public License v3.0 5 votes vote down vote up
private void acquireOntProperties() {
  for (ExtendedIterator<OntProperty> it = ontModel.listAllOntProperties(); it.hasNext(); ) {
    OntProperty p = it.next();
    if (isIgnoredOntProperty(p)) continue;
    ontProperties.add(p);
  }
}
 
Example #2
Source File: OntModelWrapper.java    From FCA-Map with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Acquire all ontology properties and skip the ignored one
 */
private void acquireProperties() {
  for (ExtendedIterator<OntProperty> it = m_ontology.listAllOntProperties(); it.hasNext(); ) {
    OntProperty p = it.next();
    if (isSkipProperty(p)) continue;
    m_properties.add(p);
  }
}
 
Example #3
Source File: ModelStorage.java    From FCA-Map with GNU General Public License v3.0 4 votes vote down vote up
public Set<OntProperty> getOntProperties() {
  return ontProperties;
}
 
Example #4
Source File: ModelStorage.java    From FCA-Map with GNU General Public License v3.0 4 votes vote down vote up
private static final boolean isIgnoredOntProperty(OntProperty p) {
  // XXX:
  return false;
}
 
Example #5
Source File: OwlSchemaFactoryTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void canGenerateDocumentSchema() throws CASRuntimeException, UIMAException {

  String ns = "http://baleen.dstl.gov.uk/document/";
  OwlSchemaFactory owlTypeSystem =
      new OwlSchemaFactory(ns, typeSystem, ImmutableList.of("internalId"));
  OntModel model = owlTypeSystem.createDocumentOntology();
  model.setNsPrefix("baleen", ns);

  try {
    assertNotNull(model);
    assertNotNull(model.getOntClass(ns + Document.class.getSimpleName()));
    assertNotNull(model.getOntClass(ns + ReferenceTarget.class.getSimpleName()));
    assertNotNull(model.getOntClass(ns + Relation.class.getSimpleName()));
    OntClass entity = model.getOntClass(ns + Entity.class.getSimpleName());
    assertNotNull(entity);
    assertEquals(
        "Type to represent named entities - values that are assigned a semantic type.",
        entity.getComment("EN"));

    assertNotNull(entity.getSuperClass());
    assertEquals(getEntityChildrenCount(), Streams.stream(entity.listSubClasses()).count());

    OntClass location = model.getOntClass(ns + Location.class.getSimpleName());
    assertEquals(entity, location.getSuperClass());
    assertEquals(1, Streams.stream(location.listSubClasses()).count());

    OntClass person = model.getOntClass(ns + Person.class.getSimpleName());
    assertEquals(entity, person.getSuperClass());
    assertEquals(0, Streams.stream(person.listSubClasses()).count());
    assertEquals(2, Streams.stream(person.listDeclaredProperties(true)).count());
    assertEquals(13, Streams.stream(person.listDeclaredProperties()).count());
    Optional<OntProperty> findFirst =
        Streams.stream(person.listDeclaredProperties(true))
            .filter(p -> "gender".equals(p.getLocalName()))
            .findFirst();
    assertTrue(findFirst.isPresent());
    assertEquals(XSD.xstring, findFirst.get().getRange());

    Optional<OntProperty> mentionOf =
        Streams.stream(person.listDeclaredProperties())
            .filter(p -> DocumentGraphFactory.MENTION_OF.equals(p.getLocalName()))
            .findFirst();
    assertTrue(mentionOf.isPresent());
    assertEquals(
        ReferenceTarget.class.getSimpleName(), mentionOf.get().getRange().getLocalName());

  } finally {
    writeToConsole(model);
  }
}
 
Example #6
Source File: OwlSchemaFactoryTest.java    From baleen with Apache License 2.0 4 votes vote down vote up
@Test
public void canGenerateEntitySchema() throws ResourceInitializationException {

  String ns = "http://baleen.dstl.gov.uk/entity/";

  OwlSchemaFactory owlTypeSystem =
      new OwlSchemaFactory(ns, typeSystem, ImmutableList.of("isNormalised", "internalId"));
  OntModel model = owlTypeSystem.createEntityOntology();
  model.setNsPrefix("baleen", ns);

  try {
    assertNotNull(model);
    assertNull(model.getOntClass(ns + Document.class.getSimpleName()));
    assertNull(model.getOntClass(ns + ReferenceTarget.class.getSimpleName()));
    assertNull(model.getOntClass(ns + Relation.class.getSimpleName()));
    OntClass entity = model.getOntClass(ns + Entity.class.getSimpleName());
    assertNotNull(entity);
    assertEquals(
        "Type to represent named entities - values that are assigned a semantic type.",
        entity.getComment("EN"));

    assertNull(entity.getSuperClass());
    assertEquals(17, Streams.stream(entity.listSubClasses()).count());

    OntClass location = model.getOntClass(ns + Location.class.getSimpleName());
    assertEquals(entity, location.getSuperClass());
    assertEquals(1, Streams.stream(location.listSubClasses()).count());

    OntClass person = model.getOntClass(ns + Person.class.getSimpleName());
    assertEquals(entity, person.getSuperClass());
    assertEquals(0, Streams.stream(person.listSubClasses()).count());
    assertEquals(2, Streams.stream(person.listDeclaredProperties(true)).count());
    assertEquals(12, Streams.stream(person.listDeclaredProperties()).count());
    Optional<OntProperty> findFirst =
        Streams.stream(person.listDeclaredProperties(true))
            .filter(p -> "gender".equals(p.getLocalName()))
            .findFirst();
    Optional<OntProperty> mentions =
        Streams.stream(person.listDeclaredProperties())
            .filter(p -> "mentions".equals(p.getLocalName()))
            .findFirst();
    assertTrue(mentions.isPresent());
    assertEquals(XSD.xstring, findFirst.get().getRange());

    Optional<OntProperty> relation =
        Streams.stream(person.listDeclaredProperties())
            .filter(p -> DocumentGraphFactory.RELATION.equals(p.getLocalName()))
            .findFirst();
    assertTrue(relation.isPresent());
    assertEquals(Entity.class.getSimpleName(), relation.get().getRange().getLocalName());
    assertEquals(Entity.class.getSimpleName(), relation.get().getDomain().getLocalName());

  } finally {
    writeToConsole(model);
  }
}
 
Example #7
Source File: OntModelWrapper.java    From FCA-Map with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Check whether the property should be skipped
 *
 * @param p property
 * @return true means the property should be ignored
 */
private static final boolean isSkipProperty(OntProperty p) {
  return false;
}
 
Example #8
Source File: OntModelWrapper.java    From FCA-Map with GNU General Public License v3.0 2 votes vote down vote up
/**
 * Get the hash set of properties
 *
 * @return m_properties
 */
public Set<OntProperty> getOntProperties() {
  return m_properties;
}