本文整理汇总了Java中org.semanticweb.owlapi.model.OWLLiteral类的典型用法代码示例。如果您正苦于以下问题:Java OWLLiteral类的具体用法?Java OWLLiteral怎么用?Java OWLLiteral使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
OWLLiteral类属于org.semanticweb.owlapi.model包,在下文中一共展示了OWLLiteral类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addToOntology
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
@Override
public void addToOntology() {
OWLObjectProperty property = featurePool.getExclusiveProperty(":propertyWithInfos");
OWLClass range = featurePool.getExclusiveClass(":ClassWithInfos");
OWLLiteral label = factory.getOWLLiteral("Comment of a property (undefined language)");
OWLAnnotationProperty comment = factory.getRDFSComment();
OWLAnnotation pA = factory.getOWLAnnotation(comment, label);
addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(property.getIRI(), pA));
OWLAnnotation cA = factory.getOWLAnnotation(comment, factory.getOWLLiteral("Comment of a class (undefined language)"));
addAxiomToOntology(factory.getOWLAnnotationAssertionAxiom(range.getIRI(), cA));
addToGenericDomainAndNewRange(property, range);
}
示例2: getPrefLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
@Override
public Set<String> getPrefLabels(OWLEntity cpt) {
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLAnnotationProperty prop = annot.getProperty();
// The DOE prefLabel, if they exist
if(prop.getIRI().equals(prefLabelIRI) ||
prop.getIRI().equals(SKOSVocabulary.PREFLABEL.getIRI()) ||
prop.getIRI().equals(OWLRDFVocabulary.RDFS_LABEL.getIRI())) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
finalLabels.add(literal.getLiteral());
}
}
}
return finalLabels;
}
示例3: getAltLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
Set<String> finalLabels = new HashSet<String>();
Set<OWLAnnotation> annotations = cpt.getAnnotations(ontology);
for(OWLAnnotation annot : annotations) {
if(annot.getValue() instanceof OWLLiteral) {
OWLAnnotationProperty prop = annot.getProperty();
// The DOE prefLabel, if they exist
if(prop.getIRI().equals(altLabelIRI) ||
prop.getIRI().equals(hiddenLabelIRI) ||
prop.getIRI().equals(SKOSVocabulary.ALTLABEL.getIRI()) ||
prop.getIRI().equals(SKOSVocabulary.HIDDENLABEL.getIRI())) {
OWLLiteral literal = (OWLLiteral)annot.getValue();
finalLabels.add(literal.getLiteral());
}
}
}
return finalLabels;
}
示例4: getAltLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt) {
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) {
finalLabels.add(((OWLLiteral)annot.getValue()).getLiteral());
}
}
return finalLabels;
}
示例5: getAllLanguageInLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
@Override
public SortedSet<String> getAllLanguageInLabels() {
if(languages == null) {
languages = new TreeSet<String>();
OWLOntologyWalker walker = new OWLOntologyWalker(Collections.singleton(ontology));
OWLOntologyWalkerVisitor<Object> visitor = new OWLOntologyWalkerVisitor<Object>(walker) {
@Override
public Object visit(OWLLiteral literal) {
if(literal.hasLang()) {
languages.add(literal.getLang());
}
return super.visit(literal);
}
};
walker.walkStructure(visitor);
}
return languages;
}
示例6: 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;
}
}
示例7: getValueAsString
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
public String getValueAsString() {
if (value instanceof IRI) {
return value.toString();
}
else if (value instanceof OWLLiteral) {
return ((OWLLiteral) value).getLiteral();
}
else if (value instanceof OWLAnonymousIndividual) {
return ((OWLAnonymousIndividual) value).getID().toString();
}
else if (value instanceof Var) {
return ((Var) value).getName();
}
else {
return value.toString();
}
}
示例8: getLabel
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
private String getLabel(OWLEntity obj) throws MultiLabelException {
String label = null;
OWLAnnotationProperty labelProperty = ont.getOWLOntologyManager().getOWLDataFactory().getRDFSLabel();
for (OWLAnnotation ann : OwlHelper.getAnnotations(obj, labelProperty, ont)) {
if (ann.getProperty().isLabel()) {
OWLAnnotationValue v = ann.getValue();
if (v instanceof OWLLiteral) {
if (label != null) {
throw new MultiLabelException(obj);
}
label = ((OWLLiteral)v).getLiteral();
}
}
}
return label;
}
示例9: getAxiomAnnotationValues
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
/**
* Retrieve the literal values for the axiom annotations with the given
* annotation property IRI.
*
* @param iri
* @param axiom
* @return literal values or null
*/
public static List<String> getAxiomAnnotationValues(IRI iri, OWLAxiom axiom) {
List<String> result = null;
for(OWLAnnotation annotation : axiom.getAnnotations()) {
OWLAnnotationProperty property = annotation.getProperty();
if (property.getIRI().equals(iri)) {
OWLAnnotationValue value = annotation.getValue();
if (value instanceof OWLLiteral) {
String literal = ((OWLLiteral) value).getLiteral();
if (result == null) {
result = Collections.singletonList(literal);
}
else if (result.size() == 1) {
result = new ArrayList<String>(result);
result.add(literal);
}
else {
result.add(literal);
}
}
}
}
return result;
}
示例10: create
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
private static JsonAnnotation create(final String key, OWLAnnotationValue value, final CurieHandler curieHandler) {
return value.accept(new OWLAnnotationValueVisitorEx<JsonAnnotation>() {
@Override
public JsonAnnotation visit(IRI iri) {
String iriString = curieHandler.getCuri(iri);
return JsonAnnotation.create(key, iriString, VALUE_TYPE_IRI);
}
@Override
public JsonAnnotation visit(OWLAnonymousIndividual individual) {
return null; // do nothing
}
@Override
public JsonAnnotation visit(OWLLiteral literal) {
return JsonAnnotation.create(key, literal.getLiteral(), getType(literal));
}
});
}
示例11: findEvidenceIndividual
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
private OWLNamedIndividual findEvidenceIndividual(OWLAnnotationValue value) {
return value.accept(new OWLAnnotationValueVisitorEx<OWLNamedIndividual>() {
@Override
public OWLNamedIndividual visit(final IRI iri) {
OWLNamedIndividual i = null;
for(OWLNamedIndividual current : model.getIndividualsInSignature()) {
if (current.getIRI().equals(iri)) {
i = current;
break;
}
}
return i;
}
@Override
public OWLNamedIndividual visit(OWLAnonymousIndividual individual) {
return null;
}
@Override
public OWLNamedIndividual visit(OWLLiteral literal) {
return null;
}
});
}
示例12: createLiteralInternal
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
private static OWLLiteral createLiteralInternal(JsonAnnotation ann, OWLDataFactory f) {
OWLLiteral literal;
OWL2Datatype datatype = null;
for(OWL2Datatype current : OWL2Datatype.values()) {
if (current.getPrefixedName().equalsIgnoreCase(ann.valueType)
|| current.getShortForm().equalsIgnoreCase(ann.valueType)) {
datatype = current;
break;
}
}
if (datatype != null) {
literal = f.getOWLLiteral(ann.value, datatype);
}
else {
literal = f.getOWLLiteral(ann.value);
}
return literal;
}
示例13: initializeLegacyRelationIndex
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
private void initializeLegacyRelationIndex() {
synchronized(legacyRelationIndex) {
OWLAnnotationProperty rdfsLabel = OWLManager.getOWLDataFactory().getRDFSLabel();
for (OWLOntology ont : this.getOntology().getImportsClosure()) {
for (OWLObjectProperty prop : ont.getObjectPropertiesInSignature()) {
for (OWLAnnotationAssertionAxiom axiom : ont.getAnnotationAssertionAxioms(prop.getIRI())) {
if (axiom.getProperty().equals(rdfsLabel)) {
Optional<OWLLiteral> literalOpt = axiom.getValue().asLiteral();
if (literalOpt.isPresent()) {
String label = literalOpt.get().getLiteral();
legacyRelationIndex.put(prop.getIRI(), label.replaceAll(" ", "_"));
}
}
}
}
}
}
}
示例14: extractEvidenceIRIValues
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
private static void extractEvidenceIRIValues(OWLAnnotation annotation, final Set<IRI> iriSet) {
if (annotation != null) {
OWLAnnotationProperty property = annotation.getProperty();
if (HAS_EVIDENCE_IRI.equals(property.getIRI()) || HAS_EVIDENCE_IRI_OLD.equals(property.getIRI())){
annotation.getValue().accept(new OWLAnnotationValueVisitor() {
@Override
public void visit(OWLLiteral literal) {
// ignore
}
@Override
public void visit(OWLAnonymousIndividual individual) {
// ignore
}
@Override
public void visit(IRI iri) {
iriSet.add(iri);
}
});
}
}
}
示例15: createDescriptor
import org.semanticweb.owlapi.model.OWLLiteral; //导入依赖的package包/类
/**
* Creates new technical descriptor from the given individual in the specified ontology.
*
* @param technicalDesc
* individual from the ontology representing technical descriptor.
* @param ontology
* currently browsed ontology.
* @param propertyIri
* IRI of the property containing technical descriptor.
* @param semantic
* constructed semantic descriptor tree root.
* @return extracted and constructed technical descriptor.
*/
private TechnicalDescriptor createDescriptor(OWLIndividual technicalDesc, OWLOntology ontology, IRI propertyIri,
SemanticDescriptor semantic) {
Set<OWLLiteral> locations = technicalDesc.getDataPropertyValues(ontologyManager.getOWLDataFactory()
.getOWLDataProperty(propertyIri), ontology);
TechnicalDescriptor result = new TechnicalDescriptor();
if (locations.size() != 1) {
throw new RuntimeException("Bad property specified or unsupported descriptor type.");
}
for (OWLLiteral location : locations) {
result.setLocationUrl(location.getLiteral().trim());
List<TechnicalDescriptor> technicalDescriptors = semantic.getTechnicalDescriptors();
for (TechnicalDescriptor technicalDescriptor : technicalDescriptors) {
if (technicalDescriptor.getLocationUrl().equals(location.getLiteral().trim())) {
return technicalDescriptor;
}
}
result.setSemanticDescriptor(semantic);
}
semantic.getTechnicalDescriptors().add(result);
return result;
}