• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java OntResource类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.jena.ontology.OntResource的典型用法代码示例。如果您正苦于以下问题:Java OntResource类的具体用法?Java OntResource怎么用?Java OntResource使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



OntResource类属于org.apache.jena.ontology包,在下文中一共展示了OntResource类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: getDisplayName

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
public static String getDisplayName(RDFNode node) {
	if (node == null)
		return "unknown";
	else if (node.isAnon())
		return "anon";
	else if (node.isLiteral())
		return node.asLiteral().getLexicalForm();
	else if (node.isResource()) {
		Resource resource = node.asResource();
		if (resource instanceof OntResource) {
			String label = ((OntResource) resource).getLabel(null);
			if (label != null)
				return label;
		}
		String localName = resource.getLocalName();
		if ((localName != null) && !localName.isEmpty())
			return localName;
		return resource.toString();
	} else
		return "unknown";
}
 
开发者ID:apache,项目名称:incubator-taverna-plugin-component,代码行数:22,代码来源:SemanticAnnotationUtils.java


示例2: addSearchTerm

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
public void addSearchTerm(String label, OntResource resource) {
  Map<OntResource, String> m = retrieve(label);
  if (m == null) {
    m = new HashMap<>();
  }
  m.put(resource, "1");
  searchTerms.put(label.toLowerCase(), m);
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:9,代码来源:LocalOntology.java


示例3: addEnumeration

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
public Resource addEnumeration(ClassInfo ci) {

		if (finalized) {
			this.result.addWarning(this, 3, ci.name());
			return null;
		}

		// create the Datatype <RDFS>
		OntResource e = ontmodel.createOntResource(
				computeReference(getPrefix(), normalizedName(ci)));

		e.addRDFType(ontmodel
				.createResource(OWLISO19150.RDF_NS_W3C_RDFS + "Datatype"));

		this.resourceByClassInfo.put(ci, e);

		applyDescriptorTargets(e, ci, DescriptorTarget.AppliesTo.CLASS);
		addConstraintDeclarations(e, ci);

		// assign stereotype information
		addCustomSubClassOf(e, ci);

		SortedMap<StructuredNumber, PropertyInfo> enumPis = ci.properties();

		if (!enumPis.isEmpty()) {

			List<Literal> enums = new ArrayList<Literal>();
			for (PropertyInfo pi : enumPis.values()) {
				Literal en = ontmodel.createLiteral(pi.name());
				enums.add(en);
			}
			e.addProperty(OWL2.oneOf, ontmodel.createList(enums.iterator()));
		}
		return e;
	}
 
开发者ID:ShapeChange,项目名称:ShapeChange,代码行数:36,代码来源:OntologyModel.java


示例4: check

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
public void check(Ontology ontology)
{
    if (ontology == null) throw new IllegalArgumentException("Ontology cannot be null");
    
    marked.put(ontology, Boolean.TRUE);
    onStack.put(ontology, Boolean.TRUE);

    ExtendedIterator<OntResource> it = ontology.listImports();
    try
    {
        while (it.hasNext())
        {
            OntResource importRes = it.next();
            if (importRes.canAs(Ontology.class))
            {
                Ontology imported = importRes.asOntology();
                if (marked.get(imported) == null)
                    check(imported);
                else if (onStack.get(imported))
                {
                    cycleOntology = imported;
                    return;
                }
            }
        }

        onStack.put(ontology, Boolean.FALSE);
    }
    finally
    {
        it.close();
    }
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:34,代码来源:OntologyProvider.java


示例5: findRO

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
private Individual findRO(OntModel model, URI base) {
	try (ClosableIterable<? extends OntResource> instances = iterate(aggregation
			.listInstances())) {
		for (OntResource o : instances)
			// System.out.println("Woo " + o);
			return o.asIndividual();
	}
	// Fallback - resolve as "/"
	// TODO: Ensure it's an Aggregation?
	return model.getIndividual(base.toString());
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:12,代码来源:RDFToManifest.java


示例6: listObjectProperties

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
private Set<Individual> listObjectProperties(OntResource ontResource,
		ObjectProperty prop) {
	LinkedHashSet<Individual> results = new LinkedHashSet<>();
	try (ClosableIterable<RDFNode> props = iterate(ontResource
			.listPropertyValues(prop))) {
		for (RDFNode node : props) {
			if (!node.isResource() || !node.canAs(Individual.class))
				continue;
			results.add(node.as(Individual.class));
		}
	}
	return results;
}
 
开发者ID:apache,项目名称:incubator-taverna-language,代码行数:14,代码来源:RDFToManifest.java


示例7: getIndividuals

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
/**
 * Returns the individuals in the range of the predicate defined in the
 * ontology.
 * 
 * @return the individuals in the range of the predicate defined in the
 *         ontology
 */
@Override
public List<Individual> getIndividuals() {
	OntModel ontology = getOntology();
	OntProperty prop = getPredicate();
	if (ontology == null || prop == null)
		return new ArrayList<>();
	OntResource range = prop.getRange();
	if (range == null)
		return new ArrayList<>();
	return ontology.listIndividuals(range).toList();
}
 
开发者ID:apache,项目名称:incubator-taverna-plugin-component,代码行数:19,代码来源:SemanticAnnotationProfileImpl.java


示例8: getRangeClass

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
@Override
public OntClass getRangeClass() {
	String clazz = this.getClassString();
	if (clazz != null)
		return componentProfile.getClass(clazz);

	OntProperty prop = getPredicate();
	if (prop == null)
		return null;
	OntResource range = prop.getRange();
	if (range != null && range.isClass())
		return range.asClass();
	return null;
}
 
开发者ID:apache,项目名称:incubator-taverna-plugin-component,代码行数:15,代码来源:SemanticAnnotationProfileImpl.java


示例9: match

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
/**
 * Matches path (relative URI) against URI templates in sitemap ontology.
 * This method uses Jersey implementation of the JAX-RS URI matching algorithm.
 * 
 * @param ontology sitemap ontology
 * @param path URI path
 * @param level
 * @return URI template/class mapping
 */    
public List<TemplatePrecedence> match(Ontology ontology, CharSequence path, int level)
{
    if (ontology == null) throw new IllegalArgumentException("Ontology cannot be null");
    if (path == null) throw new IllegalArgumentException("CharSequence cannot be null");
    
    if (log.isTraceEnabled()) log.trace("Matching path '{}' against resource templates in sitemap: {}", path, ontology);
    if (log.isTraceEnabled()) log.trace("Ontology import level: {}", level);
    List<TemplatePrecedence> matches = new ArrayList<>();

    ResIterator it = ontology.getOntModel().listResourcesWithProperty(RDF.type, LDT.Template);
    try
    {
        while (it.hasNext())
        {
            Template template = it.next().as(Template.class);
            // only match templates defined in this ontology - maybe reverse loops?
            if (template.getIsDefinedBy() != null && template.getIsDefinedBy().equals(ontology))
            {
                if (template.getPath() == null)
                {
                    if (log.isErrorEnabled()) log.error("Template class {} does not have value for {} annotation", template, LDT.path);
                    throw new OntologyException("Template class '" + template + "' does not have value for '" + LDT.path + "' annotation");
                }

                UriTemplate uriTemplate = template.getPath();
                HashMap<String, String> map = new HashMap<>();

                if (uriTemplate.match(path, map))
                {
                    if (log.isTraceEnabled()) log.trace("Path {} matched UriTemplate {}", path, uriTemplate);
                    if (log.isTraceEnabled()) log.trace("Path {} matched OntClass {}", path, template);
                    
                    TemplatePrecedence precedence = new TemplatePrecedence(template, level * -1);
                    matches.add(precedence);
                }
                else
                    if (log.isTraceEnabled()) log.trace("Path {} did not match UriTemplate {}", path, uriTemplate);
            }
        }

        List<Ontology> importedOntologies = new ArrayList<>(); // collect imports first to avoid CME within iterator
        ExtendedIterator<OntResource> importIt = ontology.listImports();
        try
        {
            while (importIt.hasNext())
            {
                OntResource importRes = importIt.next();
                if (importRes.canAs(Ontology.class)) importedOntologies.add(importRes.asOntology());
            }
        }
        finally
        {
            importIt.close();
        }
        
        //traverse imports recursively, safely make changes to OntModel outside the iterator
        for (Ontology importedOntology : importedOntologies)
            matches.addAll(match(importedOntology, path, level + 1));            
    }
    finally
    {
        it.close();
    }

    return matches;
}
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:76,代码来源:TemplateMatcher.java


示例10: match

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
public SortedSet<ClassPrecedence> match(Ontology ontology, Resource resource, Property property, int level)
   {
       if (ontology == null) throw new IllegalArgumentException("Ontology cannot be null");
if (resource == null) throw new IllegalArgumentException("Resource cannot be null");
if (property == null) throw new IllegalArgumentException("Property cannot be null");

       SortedSet<ClassPrecedence> matchedClasses = new TreeSet<>();
       ResIterator it = ontology.getOntModel().listResourcesWithProperty(LDT.segment);
       try
       {
           while (it.hasNext())
           {
               Resource ontClassRes = it.next();
               OntClass ontClass = ontology.getOntModel().getOntResource(ontClassRes).asClass();
               // only match templates defined in this ontology - maybe reverse loops?
               if (ontClass.getIsDefinedBy() != null && ontClass.getIsDefinedBy().equals(ontology) &&
                       resource.hasProperty(property, ontClass))
               {
                   ClassPrecedence template = new ClassPrecedence(ontClass, level * -1);
                   if (log.isTraceEnabled()) log.trace("Resource {} matched OntClass {}", resource, ontClass);
                   matchedClasses.add(template);
               } 
           }            
       }
       finally
       {
           it.close();
       }

       ExtendedIterator<OntResource> imports = ontology.listImports();
       try
       {
           while (imports.hasNext())
           {
               OntResource importRes = imports.next();
               if (importRes.canAs(Ontology.class))
               {
                   Ontology importedOntology = importRes.asOntology();
                   // traverse imports recursively
                   Set<ClassPrecedence> matchedImportClasses = match(importedOntology, resource, property, level + 1);
                   matchedClasses.addAll(matchedImportClasses);
               }
           }
       }
       finally
       {
           imports.close();
       }
       
       return matchedClasses;
   }
 
开发者ID:AtomGraph,项目名称:Processor,代码行数:52,代码来源:Skolemizer.java


示例11: retrieve

import org.apache.jena.ontology.OntResource; //导入依赖的package包/类
/**
 * A basic lookup function for retrieving keys (phrases or tokens)
 * from the ontology search terms map. Right now only exact lookups
 * will retrieve a result... this could be improved by using some
 * advanced parsing logic... such as Lucene query parser.
 * @param label the label (phrases or tokens) to retrieve from the 
 * ontology search terms map.
 * @return an {@link java.util.Map} if there are match(es)
 * or an empty {@link java.util.HashMap} if there are no
 * matches.
 */
public Map<OntResource, String> retrieve(String label) {
  @SuppressWarnings("unchecked")
  Map<OntResource, String> m = (Map<OntResource, String>) searchTerms.get(label.toLowerCase());
  if (m == null) {
    m = new HashMap<>();
  }
  return m;
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:20,代码来源:LocalOntology.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java SectionName类代码示例发布时间:2022-05-23
下一篇:
Java MetadataFinder类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap