本文整理匯總了Java中org.semanticweb.owlapi.model.OWLDataFactory.getOWLLiteral方法的典型用法代碼示例。如果您正苦於以下問題:Java OWLDataFactory.getOWLLiteral方法的具體用法?Java OWLDataFactory.getOWLLiteral怎麽用?Java OWLDataFactory.getOWLLiteral使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.semanticweb.owlapi.model.OWLDataFactory
的用法示例。
在下文中一共展示了OWLDataFactory.getOWLLiteral方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createLiteralInternal
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的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;
}
示例2: createOWLLiteralFromValue
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* Creates OWLLiteral from the specified Java instance.
*
* @param value The value to transform
* @param dataFactory Data factory
* @param lang Ontology language
* @return OWLLiteral representing the value
* @throws IllegalArgumentException If {@code value} is of unsupported type
*/
public static OWLLiteral createOWLLiteralFromValue(Object value, OWLDataFactory dataFactory, String lang) {
Objects.requireNonNull(value);
if (value instanceof Integer) {
// Java implementations map int/Integer to xsd:int, because xsd:integer is unbounded, whereas xsd:int is 32-bit signed, same as Java
return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_INT);
} else if (value instanceof Long) {
return dataFactory.getOWLLiteral(value.toString(), OWL2Datatype.XSD_LONG);
} else if (value instanceof Boolean) {
return dataFactory.getOWLLiteral((Boolean) value);
} else if (value instanceof Double) {
return dataFactory.getOWLLiteral((Double) value);
} else if (value instanceof String) {
return dataFactory.getOWLLiteral((String) value, lang);
} else if (value instanceof Date) {
SimpleDateFormat sdf = new SimpleDateFormat(DATE_TIME_FORMAT);
return dataFactory.getOWLLiteral(sdf.format(((Date) value)),
dataFactory.getOWLDatatype(OWL2Datatype.XSD_DATE_TIME.getIRI()));
} else if (value.getClass().isEnum()) {
return dataFactory.getOWLLiteral(value.toString());
} else {
throw new IllegalArgumentException("Unsupported value " + value + " of type " + value.getClass());
}
}
示例3: appendXrefAnnotations
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* Append xref annotations onto an existing axiom
*
* @param axiom
* @param xrefs
* @param ontology
* @return
*/
public static OWLAxiom appendXrefAnnotations(OWLAxiom axiom, Set<String> xrefs, OWLOntology ontology) {
// filter existing
Set<OWLAnnotation> newAnnotations = new HashSet<OWLAnnotation>(axiom.getAnnotations());
final OWLOntologyManager manager = ontology.getOWLOntologyManager();
final OWLDataFactory factory = manager.getOWLDataFactory();
for (String x : xrefs) {
OWLAnnotationProperty p = factory.getOWLAnnotationProperty(IRI.create("http://www.geneontology.org/formats/oboInOwl#hasDbXref"));
OWLLiteral v = factory.getOWLLiteral(x);
newAnnotations.add(factory.getOWLAnnotation(p, v));
}
final OWLAxiom newAxiom = changeAxiomAnnotations(axiom, newAnnotations, ontology);
return newAxiom;
}
示例4: addCommentToOntology
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
private void addCommentToOntology(OWLOntology ont, String cmt) {
OWLDataFactory df = getDataFactory();
OWLAnnotationProperty p =
df.getOWLAnnotationProperty(OWLRDFVocabulary.RDFS_COMMENT.getIRI());
OWLLiteral v = df.getOWLLiteral(cmt);
OWLAnnotation ann = df.getOWLAnnotation(p, v);
AddOntologyAnnotation addAnn =
new AddOntologyAnnotation(ont, ann);
getManager().applyChange(addAnn);
}
示例5: annotate
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* Convenience method for adding an annotation assertion to the
* ontology itself, taking a CURIE for the property and an Boolean literal.
*
* @param ontology the current ontology
* @param propertyCURIE will be expanded to the full annotation
* property IRI
* @param value the literal value of the annotation
* @return the annotation axiom
*/
protected static OWLAnnotation annotate(OWLOntology ontology,
String propertyCURIE, String value) {
OWLOntologyManager manager = ontology.getOWLOntologyManager();
OWLDataFactory dataFactory = manager.getOWLDataFactory();
IRI iri = format.getIRI(propertyCURIE);
OWLAnnotationProperty property =
dataFactory.getOWLAnnotationProperty(iri);
OWLLiteral literal = dataFactory.getOWLLiteral(value);
OWLAnnotation annotation = dataFactory.getOWLAnnotation(
property, literal);
manager.applyChange(
new AddOntologyAnnotation(ontology, annotation));
return annotation;
}
示例6: synonym
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
/**
* Add an synonym annotation, plus an annotation on that annotation
* that specified the type of synonym. The second annotation has the
* property oio:hasSynonymType.
*
* @param ontology the current ontology
* @param subject the subject of the annotation
* @param typeCURIE a CURIE string for the type of synonym
* @param propertyCURIE a CURIE string for the property
* @param value the string value of the synonym
* @return the axiom
*/
protected static OWLAnnotationAssertionAxiom synonym(
OWLOntology ontology, OWLEntity subject,
String typeCURIE, String propertyCURIE, String value) {
OWLDataFactory dataFactory = ontology.getOWLOntologyManager().
getOWLDataFactory();
IRI type = format.getIRI(typeCURIE);
OWLAnnotationProperty property =
dataFactory.getOWLAnnotationProperty(
format.getIRI(propertyCURIE));
OWLLiteral literal = dataFactory.getOWLLiteral(value);
return synonym(ontology, subject, type, property, literal);
}
示例7: createFuzzyAnnotation
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public static OWLAnnotation createFuzzyAnnotation(OWLDataFactory f, double value){
OWLAnnotationProperty fuzzyTag = f.getOWLAnnotationProperty(IRI.create("#fuzzyLabel"));
String fuzzyowl2 = "<fuzzyOwl2 fuzzyType=\"axiom\">\n\t<Degree value=\"" + value + "\"/></fuzzyOwl2>";
OWLLiteral fuzzyLiteral = f.getOWLLiteral(fuzzyowl2);
return f.getOWLAnnotation(fuzzyTag, fuzzyLiteral);
}
示例8: isSubDataPropertyOf
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
protected boolean isSubDataPropertyOf(OWLDataProperty subDataProperty,
OWLDataProperty superDataProperty) {
checkPreConditions(subDataProperty, superDataProperty);
if (!m_isConsistent || subDataProperty.isOWLBottomDataProperty()
|| superDataProperty.isOWLTopDataProperty())
return true;
AtomicRole subrole = H(subDataProperty);
AtomicRole superrole = H(superDataProperty);
if (m_dataRoleHierarchy != null
&& !containsFreshEntities(subDataProperty, superDataProperty)) {
HierarchyNode<AtomicRole> subroleNode = m_dataRoleHierarchy
.getNodeForElement(subrole);
return subroleNode.isEquivalentElement(superrole)
|| subroleNode.isAncestorElement(superrole);
} else {
OWLDataFactory factory = getDataFactory();
OWLIndividual individual = factory
.getOWLAnonymousIndividual("fresh-individual");
OWLLiteral freshConstant = factory.getOWLLiteral(
"internal:fresh-constant", factory.getOWLDatatype(IRI
.create("internal:anonymous-constants")));
OWLDataProperty negatedSuperDataProperty = factory
.getOWLDataProperty(IRI
.create("internal:negated-superproperty"));
OWLAxiom subpropertyAssertion = factory
.getOWLDataPropertyAssertionAxiom(subDataProperty,
individual, freshConstant);
OWLAxiom negatedSuperpropertyAssertion = factory
.getOWLDataPropertyAssertionAxiom(negatedSuperDataProperty,
individual, freshConstant);
OWLAxiom superpropertyAxiomatization = factory
.getOWLDisjointDataPropertiesAxiom(superDataProperty,
negatedSuperDataProperty);
Tableau tableau = getTableau(subpropertyAssertion,
negatedSuperpropertyAssertion, superpropertyAxiomatization);
boolean result = tableau.isSatisfiable(true, null, null, null,
null, null, ReasoningTaskDescription.isRoleSubsumedBy(
subrole, superrole, false));
tableau.clearAdditionalDLOntology();
return !result;
}
}
示例9: getDataPropertyValues
import org.semanticweb.owlapi.model.OWLDataFactory; //導入方法依賴的package包/類
public Set<OWLLiteral> getDataPropertyValues(
OWLNamedIndividual namedIndividual, OWLDataProperty property) {
checkPreConditions(namedIndividual, property);
Set<OWLLiteral> result = new HashSet<OWLLiteral>();
if (m_dlOntology.hasDatatypes()) {
OWLDataFactory factory = getDataFactory();
Set<OWLDataProperty> relevantDataProperties = getSubDataProperties(
property, false).getFlattened();
relevantDataProperties.add(property);
Set<OWLNamedIndividual> relevantIndividuals = getSameIndividuals(
namedIndividual).getEntities();
for (OWLDataProperty dataProperty : relevantDataProperties) {
if (!dataProperty.isBottomEntity()) {
AtomicRole atomicRole = H(dataProperty);
Map<Individual, Set<Constant>> dataPropertyAssertions = m_dlOntology
.getDataPropertyAssertions().get(atomicRole);
if (dataPropertyAssertions != null) {
for (OWLNamedIndividual ind : relevantIndividuals) {
Individual individual = H(ind);
if (dataPropertyAssertions.containsKey(individual)) {
for (Constant constant : dataPropertyAssertions
.get(individual)) {
String lexicalForm = constant
.getLexicalForm();
String datatypeURI = constant
.getDatatypeURI();
OWLLiteral literal;
if ((Prefixes.s_semanticWebPrefixes
.get("rdf:") + "PlainLiteral")
.equals(datatypeURI)) {
int atPosition = lexicalForm
.lastIndexOf('@');
literal = factory
.getOWLLiteral(
lexicalForm.substring(
0, atPosition),
lexicalForm
.substring(atPosition + 1));
} else
literal = factory.getOWLLiteral(
lexicalForm,
factory.getOWLDatatype(IRI
.create(datatypeURI)));
result.add(literal);
}
}
}
}
}
}
}
return result;
}