当前位置: 首页>>代码示例>>Java>>正文


Java OWLAnnotation.getValue方法代码示例

本文整理汇总了Java中org.semanticweb.owlapi.model.OWLAnnotation.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java OWLAnnotation.getValue方法的具体用法?Java OWLAnnotation.getValue怎么用?Java OWLAnnotation.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.semanticweb.owlapi.model.OWLAnnotation的用法示例。


在下文中一共展示了OWLAnnotation.getValue方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getPrefLabels

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:20,代码来源:DOEOWLContainer.java

示例2: getAltLabels

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:21,代码来源:DOEOWLContainer.java

示例3: getAltLabels

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:18,代码来源:OWLAPIContainer.java

示例4: getLabel

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:17,代码来源:GetLabelsTest.java

示例5: getVals

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private static Set<String> getVals(String p, Set<OWLAnnotation> oAnns) {
	Set<OWLAnnotation> rmAnns = new HashSet<OWLAnnotation>();
	Set<String> vs = new HashSet<String>();
	System.err.println(" L: "+p);
	for (OWLAnnotation ann : oAnns) {
		String ps = ann.getProperty().getIRI().toString();
		ps = ps.replaceAll(".*/", "");
		if (ps.equals(p)) {
			String v = (ann.getValue() instanceof OWLLiteral) ? ((OWLLiteral)ann.getValue()).getLiteral() : ann.getValue().toString();
			//String v = ann.getValue().toString();
			vs.add(v);
			System.err.println("  P: "+ps+"="+v);
			rmAnns.add(ann);
		}
	}
	oAnns.removeAll(rmAnns);
	return vs;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:19,代码来源:OntologyMetadataMarkdownWriter.java

示例6: getMappings

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
public Set<Mapping> getMappings() {
	Set<Mapping> ms = new HashSet<Mapping>();
	OWLAnnotationProperty vap = getVariableAnnotationProperty();
	for (OWLSubClassOfAxiom sca : ontology.getAxioms(AxiomType.SUBCLASS_OF, Imports.INCLUDED)) {
		Mapping m = new Mapping();
		Set<OWLAnnotation> anns = sca.getAnnotations(vap);
		for (OWLAnnotation ann : anns) {
			IRI v = (IRI) ann.getValue();
			m.vars.add(v);
		}
		if (m.vars.size() > 0) {
			m.src = sca.getSubClass();
			m.tgt = sca.getSuperClass();
			ms.add(m);
			LOG.info("MAPPING: "+m);
		}
	}
	return ms;
	
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:21,代码来源:TemplatedTransformer.java

示例7: getAxiomAnnotationValues

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:32,代码来源:AxiomAnnotationTools.java

示例8: getAnnotationValue

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的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;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:28,代码来源:OWLGraphWrapperExtended.java

示例9: getTitle

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
public static String getTitle(Iterable<OWLAnnotation> annotations) {
	if (annotations != null) {
		for (OWLAnnotation annotation : annotations) {
			String propertyId = annotation.getProperty().getIRI()
					.toString();
			OWLAnnotationValue annValue = annotation.getValue();
			String value = annValue.accept(LiteralValueVisitor.INSTANCE);
			if (value != null) {
				if ("http://purl.org/dc/elements/1.1/title"
						.equals(propertyId)) {
					return value;
				}
			}
		}
	}
	return null;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:18,代码来源:LegoMetadata.java

示例10: getOntologyAnnotationValue

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private String getOntologyAnnotationValue(OWLOntology o, OboFormatTag tag) {
	IRI dateTagIRI = Obo2Owl.trTagToIRI(tag.getTag());
	Set<OWLAnnotation> annotations = o.getAnnotations();
	for (OWLAnnotation annotation : annotations) {
		OWLAnnotationProperty property = annotation.getProperty();
		if(dateTagIRI.equals(property.getIRI())) {
			OWLAnnotationValue value = annotation.getValue();
			if (value != null) {
				if (value instanceof IRI) {
					return ((IRI) value).toString();
				}
				else if (value instanceof OWLLiteral) {
					return ((OWLLiteral) value).getLiteral();
				}
			}
		}
	}
	return null;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:20,代码来源:OWLGraphWrapperExtended.java

示例11: getSynonymStrings

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
/**
 * It returns array of synonyms (is encoded as synonym in obo format and IAO_0000118 annotation property in OWL format) of a class
 * @param c
 * @return array of strings or null
 */
@Deprecated
public String[] getSynonymStrings(OWLObject c) {
	OWLAnnotationProperty lap = getDataFactory().getOWLAnnotationProperty(IRI.create(DEFAULT_IRI_PREFIX + "IAO_0000118")); 
	Set<OWLAnnotation>anns = null;
	if (c instanceof OWLEntity) {
		anns = OwlHelper.getAnnotations((OWLEntity) c, lap, sourceOntology);
	}
	else {
		return null;
	}

	List<String> list = new ArrayList<String>();
	for (OWLAnnotation a : anns) {
		if (a.getValue() instanceof OWLLiteral) {
			OWLLiteral val = (OWLLiteral) a.getValue();
			list.add(val.getLiteral()); // return first - todo - check zero or one
		}
	}
	return list.toArray(new String[list.size()]);
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:26,代码来源:OWLGraphWrapper.java

示例12: getLanguage

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
/**
 * Returns the language.
 *
 * @param annotation the annotation
 * @return the language
 * @throws Exception the exception
 */
@SuppressWarnings("static-method")
private String getLanguage(OWLAnnotation annotation) throws Exception {
  if (annotation.getValue() instanceof OWLLiteral) {
    return ((OWLLiteral) annotation.getValue()).getLang();
  }
  // ASSUMPTION: annotation is an OWLLiteral
  else {
    // throw new Exception("Unexpected annotation that is not OWLLiteral - " +
    // annotation);
    return "";
  }
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:20,代码来源:OwlLoaderAlgorithm.java

示例13: getValue

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
/**
 * Returns the name.
 *
 * @param annotation the annotation
 * @return the name
 * @throws Exception the exception
 */
@SuppressWarnings("static-method")
private String getValue(OWLAnnotation annotation) throws Exception {
  if (annotation.getValue() instanceof OWLLiteral) {
    return ((OWLLiteral) annotation.getValue()).getLiteral();
  }
  // ASSUMPTION: annotation is an OWLLiteral
  else {
    // throw new Exception("Unexpected annotation that is not OWLLiteral - " +
    // annotation);
    return annotation.getValue().toString();
  }
}
 
开发者ID:WestCoastInformatics,项目名称:UMLS-Terminology-Server,代码行数:20,代码来源:OwlLoaderAlgorithm.java

示例14: getRdfsLabels

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
public void getRdfsLabels() {
	rdfsLabels = new HashMap<String, String>();
	prefAltLabels = new HashMap<String, String>();
	Set<OWLClass> classes = getAllConcepts();
	String prefLabelIri = "<http://www.w3.org/2004/02/skos/core#prefLabel>";
	String altLabelIri = "<http://www.w3.org/2004/02/skos/core#altLabel>";
	for (OWLClass cls : classes) {
		for (OWLAnnotation a : EntitySearcher.getAnnotations(cls, ontology)) {
			// properties are of several types: rdfs-label, altLabel or prefLabel
			OWLAnnotationProperty prop = a.getProperty();
			OWLAnnotationValue val = a.getValue();
			if (val instanceof OWLLiteral) {
				// RDFS-labels
				if (prop.isLabel()) {
					// System.out.println(cls + " labelled " + ((OWLLiteral) val).getLiteral());
					// classes can have several rdfs labels
					rdfsLabels.put(((OWLLiteral)val).getLiteral(), cls.toString());
				}
				// preferred or alternative labels
				else if (prop.toString().equals(prefLabelIri) || prop.toString().equals(altLabelIri)) {
					// System.out.println(cls + " labelled (pref or alt) " + ((OWLLiteral)
					// val).getLiteral());
					// classes can have several labels
					prefAltLabels.put(((OWLLiteral)val).getLiteral(), cls.toString());
				}
			}
		}
	}
}
 
开发者ID:ModelWriter,项目名称:Source,代码行数:30,代码来源:OntoModel.java

示例15: getLabel

import org.semanticweb.owlapi.model.OWLAnnotation; //导入方法依赖的package包/类
private String getLabel(OWLEntity e) {
	String label = null;		
	// todo - ontology import closure
	OWLAnnotationProperty property = owlDataFactory.getRDFSLabel();
	for (OWLAnnotation ann : OwlHelper.getAnnotations(e, property, sourceOntology)) {
		OWLAnnotationValue v = ann.getValue();
		if (v instanceof OWLLiteral) {
			label = ((OWLLiteral)v).getLiteral();
			break;
		}
	}
	return label;
}
 
开发者ID:owlcollab,项目名称:owltools,代码行数:14,代码来源:OldSimpleOwlSim.java


注:本文中的org.semanticweb.owlapi.model.OWLAnnotation.getValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。