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


Java ValueFactory.createBNode方法代码示例

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


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

示例1: testBlankNodes

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testBlankNodes() throws Throwable {
    IRI uriA = sail.getValueFactory().createIRI("http://example.org/test/S_POG#a");
    IRI uriB = sail.getValueFactory().createIRI("http://example.org/test/S_POG#b");
    try (SailConnection sc = getConnection()) {
        ValueFactory factory = sail.getValueFactory();
        BNode bNode = factory.createBNode();
        try {
            sc.addStatement(uriA, uriA, bNode);
        } catch (SailException se) {
            // FIXME: not supporting blank nodes ATM
            assertTrue(se.getCause() instanceof UnsupportedOperationException);
        }
        commit(sc);
    }
}
 
开发者ID:joshsh,项目名称:graphsail,代码行数:17,代码来源:SailTest.java

示例2: buildNoMapNode

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
private <ONTORES> void buildNoMapNode(OntoContainer<ONTORES> onto,
		NoMappingPossible<ONTORES> noMap, int number, Model model, ValueFactory factory,
		Resource alignmentRoot) {
	
	// ordre d'insertion des proprietes necessaires pour avoir une "belle"
	// ecriture dans le fichier RDF/XML
	
	// on créé le noeud correspondant a la Cell		
	BNode cellNode = factory.createBNode();
	// on relie l'objet "Alignement" a ce noeud par la propriete "nomap"
	model.add(alignmentRoot,NOMAP_PROPERTY,cellNode);
	// on donne le type de l'objet "Cell"
	model.add(cellNode, RDF.TYPE, CELL_TYPE);		
	
	IRI res1 = factory.createIRI(onto.getURI(noMap.getConcept())
			.toString());
	if (number == 1)
		model.add(cellNode,ENTITY1_PROPERTY,res1);
	else
		model.add(cellNode,ENTITY2_PROPERTY,res1);
	
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:23,代码来源:EuzenatRDFImpl.java

示例3: testAsRDFTermOverloads

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testAsRDFTermOverloads() {
    final RDF4J rdf4J = new RDF4J();

    final ValueFactory valueFactory = SimpleValueFactory.getInstance();

    final Value bNode = valueFactory.createBNode("b1");
    final Value iri = valueFactory.createIRI("http://ex.org");
    final Value literal = valueFactory.createLiteral("b1");

    assertEquals(rdf4J.asRDFTerm(bNode), rdf4J.asRDFTerm((BNode) bNode));
    assertEquals(rdf4J.asRDFTerm(iri), rdf4J.asRDFTerm((IRI) iri));
    assertEquals(rdf4J.asRDFTerm(literal), rdf4J.asRDFTerm((Literal) literal));
    assertEquals(rdf4J.asRDFTerm(bNode), rdf4J.asRDFTerm((Resource) bNode));
    assertEquals(rdf4J.asRDFTerm(iri), rdf4J.asRDFTerm((Resource) iri));
}
 
开发者ID:apache,项目名称:commons-rdf,代码行数:17,代码来源:RDF4JMethodOverloadsTest.java

示例4: merge

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
/**
 * Merge the value given as argument into the value factory given as argument.
 */
@SuppressWarnings("unchecked")
private <T extends Value> T merge(T value, @NonNull ValueFactory vf) {
  if (value instanceof IRI) {
    return (T) vf.createIRI(value.stringValue());
  } else if (value instanceof BNode) {
    return (T) vf.createBNode(((BNode) value).getID());
  } else {
    return value;
  }
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:14,代码来源:AbstractRdf4jBackend.java

示例5: createAnonymousType

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
private static BNode createAnonymousType(Model model, ValueFactory factory, IRI type) {
	BNode rootAlignment= factory.createBNode();
	model.add(rootAlignment, RDF.TYPE, type);
	return rootAlignment;
	
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:7,代码来源:EuzenatRDFImpl.java

示例6: buildCellNode

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
private <ONTORES1, ONTORES2> void buildCellNode(
		OntoContainer<ONTORES1> onto1, OntoContainer<ONTORES2> onto2,
		Mapping<ONTORES1, ONTORES2> mapping, Model model,
		Resource alignmentRoot, VALIDITY validityWanted) {
	ValueFactory factory = SimpleValueFactory.getInstance();
	
	VALIDITY currentMappingValidity = mapping.getValidity();
	if (validityWanted != null
			&& !currentMappingValidity.equals(validityWanted))
		return;

	// ordre d'insertion des proprietes necessaires pour avoir une "belle"
	// ecriture dans le fichier RDF/XML
	
	// on créé le noeud correspondant a la Cell		
	BNode cellNode = factory.createBNode();
	// on relie l'objet "Alignement" a ce noeud par la propriete "map"
	model.add(alignmentRoot, MAP_PROPERTY,cellNode);
	// on donne le type de l'objet "Cell"
	model.add(cellNode, RDF.TYPE, CELL_TYPE);
	
	IRI res1 = factory.createIRI(onto1.getURI(
			mapping.getFirstConcept()).toString());
	IRI res2 = factory.createIRI(onto2.getURI(
			mapping.getSecondConcept()).toString());

	
	final String comment = mapping.getComment();
	if (comment != null && !"".equals(comment)) {
		model.add(cellNode, RDFS.COMMENT,factory.createLiteral(comment));
	}
	model.add(cellNode, VALID_PROPERTY,factory.createLiteral(currentMappingValidity.toString()));
	model.add(cellNode, RELATION_PROPERTY,factory.createLiteral(mapping.getType().toString()));
	model.add(cellNode, MEASURE_PROPERTY,factory.createLiteral((float) mapping.getScore()));
	model.add(cellNode, ENTITY2_PROPERTY,res2);
	model.add(cellNode, ENTITY1_PROPERTY,res1);
	
	// we force the date format to be exactly what we want
	// see http://stackoverflow.com/questions/10614771/java-simpledateformat-pattern-for-w3c-xml-dates-with-timezone
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssX");
	model.add(cellNode, CREATION_DATE_PROPERTY,factory.createLiteral(sdf.format(mapping.getCreationDate().toDate()), XMLSchema.DATETIME));
	
	
	final String method = mapping.getMethod();
	final Map<String, String> metamap = mapping.getMeta();
	if (!method.equals(Mapping.UNKNOW_METHOD)) {
		model.add(cellNode, METHOD_PROPERTY,factory.createLiteral(method));
	}
	if (!metamap.isEmpty()) {
		Resource metaRoot = factory.createBNode();
		model.add(cellNode, METAMETHOD_PROPERTY,metaRoot);
		for (Map.Entry<String, String> entry : metamap.entrySet()) {
			IRI localProp = factory.createIRI(ALIGN_NS
					+ entry.getKey());
			model.add(metaRoot, localProp,factory.createLiteral(entry.getValue()));
		}			
	}	
	
}
 
开发者ID:lmazuel,项目名称:onagui,代码行数:60,代码来源:EuzenatRDFImpl.java

示例7: testStatsTarget

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
@Test
public void testStatsTarget() throws Exception {
    HBaseSail sail = new HBaseSail(HBaseServerTestInstance.getInstanceConfig(), "statsTable", true, -1, true, 0, null, null);
    sail.initialize();
    ValueFactory vf = SimpleValueFactory.getInstance();
    for (int i = 0; i < 1000; i++) {
        sail.addStatement((i % 13 == 0) ? vf.createBNode("id_"+i % 150) : vf.createIRI("http://whatever/subj" + (i % 150)), vf.createIRI("http://whatever/pred" + (i % 11)),  (i % 9 == 0) ? vf.createBNode("id_"+i % 100) : vf.createLiteral("whatever value " + i), i < 200 ? null : vf.createIRI("http://whatever/graph" + (i % 2)));
        sail.addStatement((i % 13 == 0) ? vf.createBNode("id_"+i % 150) : vf.createIRI("http://whatever/subj" + (i % 150)), RDF.TYPE,  vf.createIRI("http://whatever/type" + i), i < 200 ? null : vf.createIRI("http://whatever/graph" + (i % 2)));
    }
    Resource bNode = vf.createBNode("bnodeid");
    Value val = vf.createLiteral(42);
    IRI iri = vf.createIRI("http://frequent/iri");
    IRI graph0 = vf.createIRI("http://whatever/graph0");
    IRI graph1 = vf.createIRI("http://whatever/graph1");
    for (int i=0; i < 100; i++) {
        IRI iri2 = vf.createIRI("http://frequent/iri"+i);
        sail.addStatement(bNode, iri2, val);
        sail.addStatement(bNode, iri2, iri, graph0);
        sail.addStatement(iri, iri2, bNode, graph1);
    }
    sail.commit();
    sail.close();

    File root = File.createTempFile("test_stats", "");
    root.delete();
    root.mkdirs();

    assertEquals(0, ToolRunner.run(HBaseServerTestInstance.getInstanceConfig(), new HalyardStats(),
            new String[]{ "-D" + HalyardStats.SUBSET_THRESHOLD + "=100", "-s", "statsTable", "-t", root.toURI().toURL().toString() + "stats{0}.trig"}));

    File f = new File(root, "stats0.trig");
    assertTrue(f.isFile());
    System.out.println(f.getAbsolutePath());
    String content =new String(Files.readAllBytes(f.toPath()), StandardCharsets.UTF_8);
    try (FileInputStream in = new FileInputStream(f)) {
        final Model m = Rio.parse(in, "", RDFFormat.TRIG, new ParserConfig().set(BasicParserSettings.PRESERVE_BNODE_IDS, true), SimpleValueFactory.getInstance(), new ParseErrorLogger());
        try (InputStream ref = HalyardStatsTest.class.getResourceAsStream("testStatsTarget.ttl")) {
            RDFParser p = Rio.createParser(RDFFormat.TRIG);
            p.setPreserveBNodeIDs(true);
            p.setRDFHandler(new AbstractRDFHandler() {
                @Override
                public void handleStatement(Statement st) throws RDFHandlerException {
                    if (!m.contains(st.getSubject(), st.getPredicate(), st.getObject(), st.getContext())) {
                        fail(MessageFormat.format("Expected {0} in:\n{1}\n", st, content));
                    }
                }
            }).parse(ref, "");
        }
    }
}
 
开发者ID:Merck,项目名称:Halyard,代码行数:51,代码来源:HalyardStatsTest.java

示例8: export

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
public static void export(final Connection connection, final Path path)
        throws SQLException, IOException, RDFHandlerException {

    final Map<Long, String> screenNames = loadScreenNames(connection, path);

    connection.setAutoCommit(false);

    final ValueFactory vf = SimpleValueFactory.getInstance();

    try (Writer writer = new OutputStreamWriter(
            new GZIPOutputStream(new FileOutputStream(path.toFile())), Charsets.UTF_8)) {

        final RDFWriter out = Rio.createWriter(RDFFormat.NTRIPLES, writer);
        out.startRDF();

        int counter = 0;
        try (PreparedStatement stmt = connection.prepareStatement("" //
                + "SELECT resource_id, uid, score, is_alignment\n" //
                + "FROM alignments\n" //
                + "WHERE version=2\n" //
                + "ORDER BY resource_id ASC, score DESC")) {
            stmt.setFetchSize(1000);
            try (ResultSet rs = stmt.executeQuery()) {
                IRI lastEntity = null;
                int rank = 1;
                while (rs.next()) {
                    final long uid = rs.getLong("uid");
                    final String screenName = screenNames.get(uid);
                    Preconditions.checkState(screenName != null);
                    final IRI entity = vf.createIRI(rs.getString("resource_id"));
                    final IRI account = vf.createIRI(
                            "http://twitter.com/" + screenName.replaceAll("\\s", "+"));
                    final BNode candidate = vf.createBNode();
                    final float score = rs.getFloat("score");
                    final boolean align = rs.getBoolean("is_alignment");
                    rank = entity.equals(lastEntity) ? rank + 1 : 1;
                    lastEntity = entity;
                    LOGGER.debug("Processing candidate {} {} {} {}", entity, candidate, score,
                            align);
                    if (align) {
                        emit(out, entity, FOAF.ACCOUNT, account);
                    }
                    emit(out, entity, OWL.SAMEAS, entity);
                    emit(out, entity, SL.CANDIDATE_PROPERTY, candidate);
                    emit(out, candidate, SL.RANK, vf.createLiteral(rank));
                    emit(out, candidate, SL.CONFIDENCE, vf.createLiteral(score));
                    emit(out, candidate, SL.ACCOUNT, account);
                    emit(out, account, DCTERMS.IDENTIFIER, vf.createLiteral(uid));
                    emit(out, account, FOAF.ACCOUNT_NAME, vf.createLiteral(screenName));
                    if (++counter % 10000 == 0) {
                        LOGGER.info("{} candidates processed", counter);
                    }
                }
            }
        }

        out.endRDF();
    }
}
 
开发者ID:Remper,项目名称:sociallink,代码行数:60,代码来源:RDFExporter.java

示例9: export

import org.eclipse.rdf4j.model.ValueFactory; //导入方法依赖的package包/类
public Resource export(Model graph) {
    ValueFactory vf = SimpleValueFactory.getInstance();
    BNode implNode = vf.createBNode();
    graph.add(implNode, SemagrowSchema.SOURCESELECTOR, vf.createLiteral(getType()));
    return implNode;
}
 
开发者ID:semagrow,项目名称:semagrow,代码行数:7,代码来源:SourceSelectorImplConfigBase.java


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