Example #1
0
  @Test
  public void shouldTrackAnUnknownDatatype() throws Exception {

    DatatypeCount datatypeCount = new DatatypeCount();

    datatypeCount.track(new TripleBuilder().withLiteral("any string").asTriple());

    assertThat(datatypeCount.counts().get(RDFS.Literal.getURI()), equalTo(1l));
  }
Example #2
0
  @Test
  public void shouldTrackManyOccurrences() throws Exception {

    DatatypeCount datatypeCount = new DatatypeCount();

    datatypeCount
        .track(new TripleBuilder().withLiteral("35").asTriple())
        .track(new TripleBuilder().withLiteral("35").asTriple());

    assertThat(datatypeCount.counts().get(RDFS.Literal.getURI()), equalTo(2l));
  }
Example #3
0
 /**
  * Takes a DBPedia class and returns the correct label for it
  *
  * @param className Name of a class
  * @return Label
  */
 public NPPhraseSpec getNPPhrase(String className, boolean plural) {
   NPPhraseSpec object = null;
   if (className.equals(OWL.Thing.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.ENTITY.getNlr());
   } else if (className.equals(RDFS.Literal.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.VALUE.getNlr());
   } else if (className.equals(RDF.Property.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.RELATION.getNlr());
   } else if (className.equals(RDF.type.getURI())) {
     object = nlgFactory.createNounPhrase(GenericType.TYPE.getNlr());
   } else {
     String label = uriConverter.convert(className);
     if (label != null) {
       object = nlgFactory.createNounPhrase(label);
     } else {
       object = nlgFactory.createNounPhrase(GenericType.ENTITY.getNlr());
     }
   }
   object.setPlural(plural);
   return object;
 }