use of com.hp.hpl.jena.rdf.model.Literal in project lucene-skos by behas.
the class SKOSEngineImpl method indexAnnotation.
private void indexAnnotation(Resource skos_concept, Document conceptDoc, AnnotationProperty property, String field) {
StmtIterator stmt_iter = skos_concept.listProperties(property);
while (stmt_iter.hasNext()) {
Literal labelLiteral = stmt_iter.nextStatement().getObject().as(Literal.class);
String label = labelLiteral.getLexicalForm();
String labelLang = labelLiteral.getLanguage();
if (this.languages != null && !this.languages.isEmpty() && !this.languages.contains(labelLang)) {
continue;
}
// converting label to lower-case
label = label.toLowerCase(Locale.ROOT);
Field labelField = new Field(field, label, StringField.TYPE_STORED);
conceptDoc.add(labelField);
}
}
use of com.hp.hpl.jena.rdf.model.Literal in project stanbol by apache.
the class ConversionTester method testResourceJenaToOwlAxiom.
public void testResourceJenaToOwlAxiom() {
JenaToOwlConvert j2o = new JenaToOwlConvert();
OntModel model = ModelFactory.createOntologyModel();
OntClass jenaclass = model.createClass(CLAZZ.toString());
ObjectProperty jenaobprop = model.createObjectProperty(OP.toString());
DatatypeProperty jenadataprop = model.createDatatypeProperty(DP.toString());
Individual jenasub = model.createIndividual(SUBJECT.toString(), jenaclass);
Individual jenaobj = model.createIndividual(OBJECT.toString(), jenaclass);
AnnotationProperty jenaanno = model.createAnnotationProperty(label.toString());
Literal value = model.createTypedLiteral(VALUE, DATATYPE.toString());
model.add(jenasub, jenaobprop, jenaobj);
model.add(jenasub, jenadataprop, value);
model.add(jenasub, jenaanno, "Lucy", "en");
Set<OWLAxiom> owlaxiom = null;
try {
owlaxiom = j2o.ResourceJenaToOwlAxiom(jenasub, RDFXML);
if (owlaxiom == null) {
fail("Some errors occur");
} else {
StmtIterator str = model.listStatements();
int count = 0;
while (str.hasNext()) {
Statement stm = str.next();
Resource subject = stm.getSubject();
if (SUBJECT.toString().equals(subject.getURI()))
count++;
}
if (count == owlaxiom.size()) {
assertEquals(count, owlaxiom.size());
} else {
fail("The number of axioms don't match the number of statement");
}
}
} catch (Exception e) {
e.printStackTrace();
fail("Exception caugth");
} finally {
assertNotNull(owlaxiom);
}
}
Aggregations