本文整理汇总了Java中org.semanticweb.owlapi.model.OWLLiteral.hasLang方法的典型用法代码示例。如果您正苦于以下问题:Java OWLLiteral.hasLang方法的具体用法?Java OWLLiteral.hasLang怎么用?Java OWLLiteral.hasLang使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.semanticweb.owlapi.model.OWLLiteral
的用法示例。
在下文中一共展示了OWLLiteral.hasLang方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getPrefLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
@Override
public Set<String> getPrefLabels(OWLEntity cpt, String lang) {
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();
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(""))) {
finalLabels.add(literal.getLiteral());
}
}
}
}
return finalLabels;
}
示例2: getAltLabels
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
@Override
public Set<String> getAltLabels(OWLEntity cpt, String lang) {
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();
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(""))) {
finalLabels.add(literal.getLiteral());
}
}
}
}
return finalLabels;
}
示例3: 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;
}
示例4: 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;
}
示例5: visit
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
public Object visit(OWLLiteral object) {
try {
if (object.isRDFPlainLiteral()) {
if (object.hasLang())
return Constant.create(object.getLiteral()+"@"+object.getLang(),Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
else
return Constant.create(object.getLiteral()+"@",Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
}
else
return Constant.create(object.getLiteral(),object.getDatatype().getIRI().toString());
}
catch (UnsupportedDatatypeException e) {
if (m_ignoreUnsupportedDatatypes) {
if (m_warningMonitor!=null)
m_warningMonitor.warning("Ignoring unsupported datatype '"+object.toString()+"'.");
return Constant.createAnonymous(object.getLiteral());
}
else
throw e;
}
}
示例6: getConstant
import org.semanticweb.owlapi.model.OWLLiteral; //导入方法依赖的package包/类
protected Constant getConstant(OWLLiteral literal) {
try {
if (literal.isRDFPlainLiteral()) {
if (literal.hasLang())
return Constant.create(literal.getLiteral()+"@"+literal.getLang(),Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
else
return Constant.create(literal.getLiteral()+"@",Prefixes.s_semanticWebPrefixes.get("rdf:")+"PlainLiteral");
}
else
return Constant.create(literal.getLiteral(),literal.getDatatype().getIRI().toString());
}
catch (UnsupportedDatatypeException e) {
if (m_ignoreUnsupportedDatatypes) {
if (m_warningMonitor!=null)
m_warningMonitor.warning("Ignoring unsupported datatype '"+literal.toString()+"'.");
return Constant.createAnonymous(literal.getLiteral());
}
else
throw e;
}
}