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

Java Literal类代码示例

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

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



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

示例1: generateRdf

import org.apache.clerezza.rdf.core.Literal; //导入依赖的package包/类
/**
 * Get SIOC content from the RDF as text and return it.
 *
 * @param entity
 * @return
 * @throws IOException
 */
@Override
protected TripleCollection generateRdf(HttpRequestEntity entity) throws IOException {
    String text = "";
    Graph graph = Parser.getInstance().parse(entity.getData(), "text/turtle");
    Iterator<Triple> triples = graph.filter(null, SIOC.content, null);
    if (triples.hasNext()) {
        Literal literal = (Literal) triples.next().getObject();
        text = literal.getLexicalForm();
    }

    final TripleCollection result = new SimpleMGraph();
    final Resource resource = entity.getContentLocation() == null
            ? new BNode()
            : new UriRef(entity.getContentLocation().toString());
    final GraphNode node = new GraphNode(resource, result);
    node.addProperty(RDF.type, TEXUAL_CONTENT);
    node.addPropertyValue(SIOC.content, text);
    node.addPropertyValue(new UriRef("http://example.org/ontology#textLength"), text.length());
    return result;
}
 
开发者ID:fusepoolP3,项目名称:p3-pipeline-transformer,代码行数:28,代码来源:SimpleRdfConsumingTransformer.java


示例2: graphToJson

import org.apache.clerezza.rdf.core.Literal; //导入依赖的package包/类
private JSONArray graphToJson(MGraph graph) throws JSONException{
	//JSONObject json = new JSONObject();
	JSONArray json = new JSONArray();
	
	//create the first 0 element "non assigné"
	json.put(getBudgetLineObject("0", "Non assigné", 0));
	
	//TODO : use ldpath for building this ones
	
	//1) get all budget lines
	Iterator<Triple> budgetLinesId = graph.filter(null, RDF.type,Onthology.budgetLineType.getUri());
	while(budgetLinesId.hasNext()){
		Triple budgetId = budgetLinesId.next();
		
		//getthe label
		Resource label = graph.filter(budgetId.getSubject(), SKOS.prefLabel, null).next().getObject();
		
		//get the value
		Triple valueId = graph.filter(null, Onthology.forBudgetLine.getUri(), budgetId.getSubject()).next();
		Resource percentage = graph.filter(valueId.getSubject(), Onthology.percentage.getUri(), null).next().getObject();
		
		json.put(getBudgetLineObject(budgetId.getSubject().toString(), ((Literal)label).getLexicalForm(), Double.parseDouble(((Literal)percentage).getLexicalForm())));
		
	}
	return json;
}
 
开发者ID:florent-andre,项目名称:CleverTaxes,代码行数:27,代码来源:SkosifierRootResource.java


示例3: handleStatement

import org.apache.clerezza.rdf.core.Literal; //导入依赖的package包/类
private void handleStatement(RDFDataset result, Triple t, Map<BNode, String> bNodeMap) {
    final String subject = getResourceValue(t.getSubject(), bNodeMap);
    final String predicate = getResourceValue(t.getPredicate(), bNodeMap);
    final Resource object = t.getObject();

    if (object instanceof Literal) {

        final String value = ((Literal) object).getLexicalForm();
        final String language;
        final String datatype;
        if (object instanceof TypedLiteral) {
            language = null;
            datatype = getResourceValue(((TypedLiteral) object).getDataType(), bNodeMap);
        } else if (object instanceof PlainLiteral) {
            // we use RDF 1.1 literals so we do set the RDF_LANG_STRING
            // datatype
            datatype = RDF_LANG_STRING;
            final Language l = ((PlainLiteral) object).getLanguage();
            if (l == null) {
                language = null;
            } else {
                language = l.toString();
            }
        } else {
            throw new IllegalStateException("Unknown Literal class "
                    + object.getClass().getName());
        }
        result.addTriple(subject, predicate, value, datatype, language);
        count++;
    } else {
        result.addTriple(subject, predicate, getResourceValue((NonLiteral) object, bNodeMap));
        count++;
    }

}
 
开发者ID:jsonld-java,项目名称:jsonld-java-clerezza,代码行数:36,代码来源:ClerezzaRDFParser.java


示例4: addSubjects

import org.apache.clerezza.rdf.core.Literal; //导入依赖的package包/类
/**
 * Add dc:subject property to items pointing to entities extracted by NLP
 * engines in the default chain. Given a node and a TripleCollection
 * containing fise:Enhancements about that node dc:subject properties are
 * added to an item pointing to entities referenced by those enhancements if
 * the enhancement confidence value is above a threshold.
 *
 * @param node
 * @param metadata
 */
private void addSubjects(MGraph targetGraph, UriRef itemRef, TripleCollection metadata) {
    final GraphNode enhancementType = new GraphNode(TechnicalClasses.ENHANCER_ENHANCEMENT, metadata);
    final Set<UriRef> entities = new HashSet<UriRef>();
    // get all the enhancements
    final Iterator<GraphNode> enhancements = enhancementType.getSubjectNodes(RDF.type);
    while (enhancements.hasNext()) {
        final GraphNode enhhancement = enhancements.next();
        final Iterator<Literal> confidenceLiterals = enhhancement.getLiterals(org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_CONFIDENCE);
        //look the confidence value for each enhancement
        double enhancementConfidence = confidenceLiterals.hasNext() ? 
                LiteralFactory.getInstance().createObject(Double.class,
                (TypedLiteral) confidenceLiterals.next())  : 1;
        if (enhancementConfidence >= confidenceThreshold) {
            // get entities referenced in the enhancement 
            final Iterator<Resource> referencedEntities = enhhancement.getObjects(org.apache.stanbol.enhancer.servicesapi.rdf.Properties.ENHANCER_ENTITY_REFERENCE);
            while (referencedEntities.hasNext()) {
                final UriRef entity = (UriRef) referencedEntities.next();
                // Add dc:subject to the patent for each referenced entity
                targetGraph.add(new TripleImpl(itemRef, DC.subject, entity));
                entities.add(entity);
            }
        }

    }
    for (UriRef uriRef : entities) {
        // We don't get the entity description directly from metadata
        // as the context there would include
        addResourceDescription(uriRef, targetGraph);
    }
}
 
开发者ID:fusepool,项目名称:datalifecycle,代码行数:41,代码来源:SourcingAdmin.java


示例5: readDictionary

import org.apache.clerezza.rdf.core.Literal; //导入依赖的package包/类
public static DictionaryStore readDictionary(InputStream inputStream) {
    Triple triple;
    Resource resource;
    String label, lang;

    DictionaryStore dictionary = new DictionaryStore();
    MGraph graph = new IndexedMGraph();
    Parser.getInstance().parse(graph, inputStream, "application/rdf+xml");
    Iterator<Triple> typeTriples = graph.filter(null, RDF.type, SKOS04.Concept);
    while (typeTriples.hasNext()) {
        NonLiteral s = typeTriples.next().getSubject();
        if (s instanceof UriRef) {
            UriRef concept = (UriRef) s;

            // getting prefLabels
            Iterator<Triple> prefTriples = graph.filter(concept, SKOS04.prefLabel, null);
            while (prefTriples.hasNext()) {
                triple = prefTriples.next();
                resource = triple.getObject();
                if (resource instanceof PlainLiteral) {
                    label = ((PlainLiteral) resource).getLexicalForm();
                    lang = ((PlainLiteral) resource).getLanguage() == null ? null : ((PlainLiteral) resource).getLanguage().toString();
                } else if (resource instanceof TypedLiteral && ((TypedLiteral) resource).getDataType().equals(XSD.string)) {
                    label = ((Literal) resource).getLexicalForm();
                    lang = null;
                } else {
                    label = null;
                    lang = null;
                }

                if (StringUtils.isNotBlank(label) && StringUtils.isNotBlank(concept.getUnicodeString())) {
                    dictionary.addOriginalElement(label, SKOS04.prefLabel, concept.getUnicodeString());
                }
            }

            // getting altLabels
            Iterator<Triple> altTriples = graph.filter(concept, SKOS04.altLabel, null);
            while (altTriples.hasNext()) {
                triple = altTriples.next();
                resource = triple.getObject();
                if (resource instanceof PlainLiteral) {
                    label = ((PlainLiteral) resource).getLexicalForm();
                    lang = ((PlainLiteral) resource).getLanguage() == null ? null : ((PlainLiteral) resource).getLanguage().toString();
                } else if (resource instanceof TypedLiteral && ((TypedLiteral) resource).getDataType().equals(XSD.string)) {
                    label = ((Literal) resource).getLexicalForm();
                    lang = null;
                } else {
                    label = null;
                    lang = null;
                }

                if (StringUtils.isNotBlank(label) && StringUtils.isNotBlank(concept.getUnicodeString())) {
                    dictionary.addOriginalElement(label, SKOS04.altLabel, concept.getUnicodeString());
                }
            }

        }
    }
    return dictionary;
}
 
开发者ID:fusepoolP3,项目名称:p3-dictionary-matcher-transformer,代码行数:61,代码来源:Reader.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java MQVPublicParameters类代码示例发布时间:2022-05-23
下一篇:
Java EParentCommand类代码示例发布时间: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