本文整理汇总了Java中org.semanticweb.owlapi.model.OWLLiteral.getLiteral方法的典型用法代码示例。如果您正苦于以下问题:Java OWLLiteral.getLiteral方法的具体用法?Java OWLLiteral.getLiteral怎么用?Java OWLLiteral.getLiteral使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.model.OWLLiteral
的用法示例。
在下文中一共展示了OWLLiteral.getLiteral方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAltLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt, String lang) {
if(cpt == null)
throw new IllegalArgumentException("cpt cannot be null");
// The rdfs:label, if it exists
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(
ontology,
df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_LABEL.getIRI()));
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
// Si il y a une langue et que c'est celle en parametre
if((literal.hasLang() && literal.getLang().toLowerCase().equals(lang.toLowerCase()))
// ou si il n'y en a pas et que c'est voulu
|| (!literal.hasLang() && lang.equals(""))) {
String label = literal.getLiteral();
finalLabels.add(label);
}
}
}
return finalLabels;
}
示例2: visit
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
public void visit(OWLLiteral literal){
literal_str = literal.getLiteral();
if (literal.isDouble()){
owlMappingAxiomVisitor.setMeasure(literal.parseDouble());
}
else {
if (literal_str.equals("=")){
owlMappingAxiomVisitor.setRelation(Utilities.EQ);
}
else if (literal_str.equals(">")){
owlMappingAxiomVisitor.setRelation(Utilities.R2L);
}
else if (literal_str.equals("<")){
owlMappingAxiomVisitor.setRelation(Utilities.L2R);
}
}
}
示例3: tr
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
private OWLAxiom tr(OWLClass c, OWLAnnotationAssertionAxiom ax) {
OWLAnnotationProperty p = ax.getProperty();
if (!ecmap.containsKey(c)) {
// preserve as-is, exception for labels
if (p.isLabel()) {
OWLLiteral lit = (OWLLiteral) ax.getValue();
String newVal = lit.getLiteral() + " (" + suffix + ")";
return fac.getOWLAnnotationAssertionAxiom(ax.getProperty(),
ax.getSubject(), fac.getOWLLiteral(newVal));
}
return ax;
} else {
// the class is merged - ditch its axioms
// (in future some may be preserved - syns?)
// fac.getOWLAnnotationAssertionAxiom(ax.getProperty(), ecmap,
// ax.getValue());
return null;
}
}
示例4: getAnnotationValue
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
/**
* fetches the value of a single-valued annotation property for an OWLObject
* <p>
* TODO: provide a flag that determines behavior in the case of >1 value
*
* @param c
* @param lap
* @return value
*/
public String getAnnotationValue(OWLObject c, OWLAnnotationProperty lap) {
Set<OWLAnnotation>anns = new HashSet<OWLAnnotation>();
if (c instanceof OWLEntity) {
for (OWLOntology ont : getAllOntologies()) {
anns.addAll(OwlHelper.getAnnotations((OWLEntity) c, lap, ont));
}
}
else {
return null;
}
for (OWLAnnotation a : anns) {
if (a.getValue() instanceof OWLLiteral) {
OWLLiteral val = (OWLLiteral) a.getValue();
return val.getLiteral(); // return first - TODO - check zero or one
}
}
return null;
}
示例5: extractServiceName
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
/**
* Extracts service name from profile ontology.
*
* @param profile
* profile individual found in ontology.
* @param profileOntology
* searched profile ontology.
* @return extracted service name.
* @throws EntryCreationException
* should any problems with extraction of data manipulation service information occur.
*/
private String extractServiceName(OWLIndividual profile, OWLOntology profileOntology)
throws EntryCreationException {
Set<OWLLiteral> names = profile.getDataPropertyValues(
ontologyManager.getOWLDataFactory().getOWLDataProperty(
IRI.create("http://www.daml.org/services/owl-s/1.2/Profile.owl#serviceName")), profileOntology);
for (OWLLiteral name : names) {
return name.getLiteral();
}
throw new EntryCreationException(
"Could not find service name in profile ontology - malformed semantic descriptor.");
}
示例6: extractServiceDescription
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
/**
* Extracts service name of described service.
*
* @param profile
* profile individual found in ontology.
* @param profileOntology
* profile ontology.
* @return extracted service description.
*/
private String extractServiceDescription(OWLIndividual profile, OWLOntology profileOntology) {
Set<OWLLiteral> descriptions = profile.getDataPropertyValues(ontologyManager.getOWLDataFactory()
.getOWLDataProperty(IRI.create("http://www.daml.org/services/owl-s/1.2/Profile.owl#textDescription")),
profileOntology);
for (OWLLiteral description : descriptions) {
return description.getLiteral();
}
return null;
}
示例7: owlLiteralToValue
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
/**
* Transforms OWLLiteral to a plain Java object (boxed primitive or date/time).
*
* @param literal The literal to transform
* @return Transformed value
* @throws IllegalArgumentException If the literal is of unsupported type
*/
public static Object owlLiteralToValue(final OWLLiteral literal) {
if (literal.isRDFPlainLiteral()) {
return literal.getLiteral();
} else if (literal.getDatatype().isBuiltIn())
switch (literal.getDatatype().getBuiltInDatatype()) {
case XSD_SHORT:
return Short.parseShort(literal.getLiteral());
case XSD_LONG:
return Long.parseLong(literal.getLiteral());
case XSD_INT:
case XSD_INTEGER:
return Integer.parseInt(literal.getLiteral());
case XSD_DOUBLE:
case XSD_DECIMAL:
return Double.parseDouble(literal.getLiteral());
case XSD_FLOAT:
return Float.parseFloat(literal.getLiteral());
case XSD_STRING:
case RDF_XML_LITERAL:
case RDF_LANG_STRING:
return literal.getLiteral();
case XSD_BOOLEAN:
return Boolean.parseBoolean(literal.getLiteral());
case XSD_ANY_URI:
return URI.create(literal.getLiteral());
case XSD_DATE_TIME_STAMP:
case XSD_DATE_TIME:
try {
return new SimpleDateFormat(DATE_TIME_FORMAT).parse(literal.getLiteral());
} catch (ParseException e) {
throw new IllegalArgumentException(
"The date time '" + literal.getLiteral() + "' cannot be parsed.");
}
}
throw new IllegalArgumentException("Unsupported datatype: " + literal.getDatatype());
}
示例8: transform
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
public static Object transform(final OWLLiteral l) {
if (l.isRDFPlainLiteral()) {
return l.getLiteral();
} else if (l.getDatatype().isBuiltIn())
switch (l.getDatatype().getBuiltInDatatype()) {
case XSD_SHORT:
return Short.parseShort(l.getLiteral());
case XSD_LONG:
return Long.parseLong(l.getLiteral());
case XSD_INT:
case XSD_INTEGER:
return Integer.parseInt(l.getLiteral());
case XSD_DOUBLE:
case XSD_DECIMAL:
return Double.parseDouble(l.getLiteral());
case XSD_FLOAT:
return Float.parseFloat(l.getLiteral());
case XSD_STRING:
case RDF_XML_LITERAL:
return l.getLiteral();
case XSD_BOOLEAN:
return Boolean.parseBoolean(l.getLiteral());
case XSD_ANY_URI:
return URI.create(l.getLiteral());
case XSD_DATE_TIME_STAMP:
case XSD_DATE_TIME:
try {
return new SimpleDateFormat("yyyy-MM-dd'T'hh:mm:ss")
.parse(l.getLiteral());
} catch (ParseException e) {
throw new IllegalArgumentException("The date time '"
+ l.getLiteral() + "' cannot be parsed");
}
}
throw new IllegalArgumentException("Unsupported datatype: "
+ l.getDatatype());
}
示例9: getOBOSynonyms
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
private Set<ISynonym> getOBOSynonyms(OWLEntity e, Obo2OWLVocabulary vocabulary, OWLOntology ont) {
OWLAnnotationProperty synonymProperty = getDataFactory().getOWLAnnotationProperty(vocabulary.getIRI());
Set<OWLAnnotation> anns = OwlHelper.getAnnotations(e, synonymProperty, ont);
Set<OWLAnnotationAssertionAxiom> annotationAssertionAxioms = ont.getAnnotationAssertionAxioms(e.getIRI());
if (anns != null && !anns.isEmpty()) {
Set<ISynonym> set = new HashSet<ISynonym>();
for (OWLAnnotation a : anns) {
if (a.getValue() instanceof OWLLiteral) {
OWLLiteral val = (OWLLiteral) a.getValue();
String label = val.getLiteral();
if (label != null && label.length() > 0) {
String category = null;
Set<String> xrefs = null;
SynonymDetails details = getOBOSynonymDetails(annotationAssertionAxioms, val, synonymProperty);
if (details != null) {
category = details.category;
xrefs = details.xrefs;
}
Synonym s = new Synonym(label, vocabulary.getMappedTag(), category, xrefs);
set.add(s);
}
}
}
if (!set.isEmpty()) {
return set;
}
}
return null;
}
示例10: getFirstLiteral
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
/**
* Convenience method to get the first string literal of an
* annotation property.
*
* @param ontology the current ontology
* @param taxon the subject
* @param property the property
* @return null or the label content
*/
protected static String getFirstLiteral(OWLOntology ontology,
OWLEntity taxon, OWLAnnotationProperty property) {
Set<OWLAnnotationAssertionAxiom> axioms = ontology.getAnnotationAssertionAxioms(taxon.getIRI());
for (OWLAnnotationAssertionAxiom axiom : axioms) {
if (property.equals(axiom.getProperty())) {
OWLAnnotationValue value = axiom.getValue();
if (value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral)value;
return literal.getLiteral();
}
}
}
return null;
}
示例11: renderMarkdown
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
public static String renderMarkdown(OWLGraphWrapper g, String baseDir, boolean isIncludeImage) {
OWLOntology ont = g.getSourceOntology();
StringBuilder out = new StringBuilder();
String ontId = g.getOntologyId();
Set<OWLAnnotation> oAnns = ont.getAnnotations();
System.err.println("NUM1:"+oAnns.size());
String title = getVal("title", oAnns);
out.append("## Ontology: "+title+"\n\n");
out.append("IRI: "+rurl(ont)+"\n\n");
String desc = getVal("description", oAnns);
out.append("### Description\n\n");
out.append(desc+"\n\n");
Set<OWLOntology> imports = ont.getImports();
if (imports.size() > 0) {
out.append("### Imports\n\n");
for (OWLOntology im : imports) {
out.append(" * "+rurl(im)+"\n");
}
}
if (isIncludeImage) {
String imgFn = baseDir + "/" + ontId + ".png";
out.append("![]("+imgFn+")\n\n");
}
System.err.println("NUM:"+oAnns.size());
if (oAnns.size() > 0) {
out.append("### Annotations:\n\n");
for (OWLAnnotation ann : oAnns) {
String annLabel = g.getLabelOrDisplayId(ann.getProperty());
OWLAnnotationValue v = ann.getValue();
String dv = v.toString();
if (v instanceof OWLLiteral) {
OWLLiteral lv = ((OWLLiteral)v);
dv = lv.getLiteral();
IRI dt = lv.getDatatype().getIRI();
//System.out.println("DT = "+dt);
if (dt.equals(OWL2Datatype.XSD_ANY_URI.getIRI())) {
dv = href(lv.getLiteral());
}
}
out.append(" * "+href(ann.getProperty().getIRI().toString(),annLabel)+" : "+dv+"\n");
}
}
return out.toString();
}
示例12: getIRIByIdentifier
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
public IRI getIRIByIdentifier(String id, boolean isAutoResolve) {
if (isAutoResolve) {
OWLObject obj = this.getObjectByAltId(id);
if (obj != null) {
return ((OWLNamedObject) obj).getIRI();
}
}
// special magic for finding IRIs from a non-standard identifier
// This is the case for relations (OWLObject properties) with a short hand
// or for relations with a non identifiers with-out a colon, e.g. negative_regulation
if (!id.contains(":")) {
final OWLAnnotationProperty shortHand = getDataFactory().getOWLAnnotationProperty(Obo2OWLVocabulary.IRI_OIO_shorthand.getIRI());
final OWLAnnotationProperty oboIdInOwl = getDataFactory().getOWLAnnotationProperty(Obo2Owl.trTagToIRI(OboFormatTag.TAG_ID.getTag()));
for (OWLOntology o : getAllOntologies()) {
for(OWLObjectProperty p : o.getObjectPropertiesInSignature()) {
// check for short hand or obo ID in owl
Set<OWLAnnotation> annotations = OwlHelper.getAnnotations(p, o);
if (annotations != null) {
for (OWLAnnotation owlAnnotation : annotations) {
OWLAnnotationProperty property = owlAnnotation.getProperty();
if ((shortHand != null && shortHand.equals(property))
|| (oboIdInOwl != null && oboIdInOwl.equals(property)))
{
OWLAnnotationValue value = owlAnnotation.getValue();
if (value != null && value instanceof OWLLiteral) {
OWLLiteral literal = (OWLLiteral) value;
String shortHandLabel = literal.getLiteral();
if (id.equals(shortHandLabel)) {
return p.getIRI();
}
}
}
}
}
}
}
}
// otherwise use the obo2owl method
Obo2Owl b = new Obo2Owl(getManager()); // re-use manager, creating a new one can be expensive as this is a highly used code path
b.setObodoc(new OBODoc());
return b.oboIdToIRI(id);
}
示例13: visit
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
@Override
public String visit(OWLLiteral literal) {
return literal.getLiteral();
}