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


Java Literal.getDatatypeURI方法代码示例

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


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

示例1: buildNext

import org.apache.jena.rdf.model.Literal; //导入方法依赖的package包/类
@Override
protected Indexable buildNext(Statement statement) {
    InstanceEntity instanceEntity = createInstance(applyNS(statement.getSubject().getURI()));
    PropertyEntity propertyEntity = createProperty(applyNS(statement.getPredicate().getURI()));

    LabeledEntity labeledEntity;

    if (!statement.getObject().isLiteral()) {
        //Is created as an instance but can be changed to a class down on the workflow in EntityClassifierProcessor.
        labeledEntity = createInstance(applyNS(statement.getObject().asResource().getURI()));
    } else {
        Literal literal = statement.getObject().asLiteral();
        String dataType = literal.getDatatypeURI();
        String langTag = literal.getLanguage();
        String value = literal.getLexicalForm();
        labeledEntity = new ValueEntity(value, dataType, langTag);
    }


    return new Indexable(new Fact(kbId, instanceEntity, propertyEntity, labeledEntity), kbId);
}
 
开发者ID:Lambda-3,项目名称:Stargraph,代码行数:22,代码来源:FactIterator.java

示例2: getDeduplication

import org.apache.jena.rdf.model.Literal; //导入方法依赖的package包/类
private Set<String> getDeduplication(StringBuilder builder, Triple[] triples) {
	// Deduplicate with HashSet
	Set<String> deduplicate = new HashSet<String>();

	for (Triple triple : triples) {

		StringBuilder builder2 = new StringBuilder();
		builder2.append(" <").append(resource).append(triple.getSubject()).append("> ");
		deduplicate.add(builder.toString() + builder2.toString());

		builder2.append(" <").append(properties).append(triple.getPredicate()).append("> ");

		if (triple.isObjectResource()) {
			builder2.append(" <").append(resource).append(triple.getObject()).append("> ");
		} else {
			Model empty = ModelFactory.createDefaultModel();
			Literal l = empty.createTypedLiteral(triple.getObject());
			String obj = "\"" + l.getValue() + "\"^^<" + l.getDatatypeURI() + ">";
			builder2.append(obj);
		}

		deduplicate.add(builder2.toString());
	}
	return deduplicate;
}
 
开发者ID:dice-group,项目名称:IGUANA,代码行数:26,代码来源:TripleBasedStorage.java

示例3: parse

import org.apache.jena.rdf.model.Literal; //导入方法依赖的package包/类
@Override
public RDFDataset parse(Object input) throws JsonLdError {
    RDFDataset dataset = new RDFDataset();
    Model m = (Model)input;
    for (StmtIterator i = m.listStatements(); i.hasNext(); ) {
        Statement stmt = i.next();
        String s = idForResource( stmt.getSubject() );
        String p = idForResource( stmt.getPredicate() );
        RDFNode o = stmt.getObject();
        if( o.isLiteral() ) {
            Literal l = o.asLiteral();
            String lang = l.getLanguage();
            if (lang != null && lang.length() == 0) {
                lang = null ;
            }
            String dt = l.getDatatypeURI();
            if (dt == null ) {
                dt = XSDDatatype.XSDstring.getURI() ;
            }
            dataset.addTriple(s, p, l.getLexicalForm(), dt, lang);
        } else {
            dataset.addTriple(s, p, idForResource( o.asResource() ));
        }
    }
    return dataset;
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:27,代码来源:JenaJSONLDParser.java

示例4: formatNode

import org.apache.jena.rdf.model.Literal; //导入方法依赖的package包/类
public static String formatNode(RDFNode node) {
    if (node.isURIResource()) {
        return "<" + node.asResource().getURI().trim().replace(" ", "") + ">";
    }
    if (node.isLiteral()){
        Literal value = node.asLiteral();
        String formattedValue = "\"" + value.getLexicalForm() + "\"";
        if (!value.getLanguage().isEmpty()) {
            formattedValue += "@" + value.getLanguage() ;
        }
        if (!value.getDatatypeURI().isEmpty()
                && !value.getDatatypeURI().endsWith("langString")
                && !value.getDatatypeURI().equals("http://www.w3.org/2001/XMLSchema#string")) {
            formattedValue += "^^<" + value.getDatatypeURI() + ">" ;
        }

        return  formattedValue;
    }
    throw new IllegalArgumentException("cannot support blank nodes as targets");
}
 
开发者ID:AKSW,项目名称:RDFUnit,代码行数:21,代码来源:NodeFormatter.java

示例5: encode

import org.apache.jena.rdf.model.Literal; //导入方法依赖的package包/类
public static String encode(RDFNode value, PrefixMapping prefixes, boolean embedded, Set<Resource> seen) {
    if (value.isResource()) {
        Resource r = value.asResource();
        if (value.isURIResource()) {
            return asPrefixOrURI( r.getURI(), prefixes);
        } else {
            return serializeBnode(r, prefixes, seen);
        }
    } else {
        Literal l = value.asLiteral();
        String lex = l.getLexicalForm();
        if (l.getLanguage() == null || l.getLanguage().isEmpty()) {
            if (l.getDatatype() == null || l.getDatatypeURI().equals(XSD.xstring.getURI())) {
                if (embedded) {
                    if (lex.contains("\n")) {
                        return "'''" + lex + "'''";
                    } else {
                        return "'" + lex.replace("'", "\\'") + "'";
                    }
                } else {
                    if (TRAP_PATTERN.matcher(lex).matches() || lex.contains(VALUE_SEP)) {
                        // String that looks like a number or boolean so quote it
                        return "'" + lex.replace("'", "\\'") + "'";
                    } else {
                        return lex;
                    }
                }
            } else {
                String dt = l.getDatatypeURI();
                for (String nt : NUMERIC_TYPES) {
                    if (dt.equals(nt)) {
                        return l.getLexicalForm();   // Treat numbers as plain, means round trip isn't safe TODO Review this 
                    }
                }
                return String.format("'%s'^^%s", lex, asPrefixOrURI(dt, prefixes));
            }
        } else {
            return String.format("'%s'@%s", lex, l.getLanguage());
        }
    }
}
 
开发者ID:UKGovLD,项目名称:registry-core,代码行数:42,代码来源:RDFCSVUtil.java


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