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


Java Serializer.serialize方法代码示例

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


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

示例1: findSameEntities

import org.apache.clerezza.rdf.core.serializedform.Serializer; //导入方法依赖的package包/类
/**
 * The client RDF data is always used as the source data source, of type file, for the comparisons with a target data source. 
 * The target data source can be of type file or a SPARQL endpoint. If the target data source in the Silk config file
 * is set to be of type file then the same client data will be used and the task is a deduplication task (Silk works only with local files). 
 * The updated configuration file and the input RDF data and the output files are stored in the /tmp/ folder.
 * @param inputRdf
 * @return
 * @throws IOException
 */
protected TripleCollection findSameEntities(InputStream inputRdf, String rdfFormat, InputStream configIn) throws IOException {    	
	// Default silk config file
	File configFile = null;
	if(configIn != null){
		configFile = FileUtil.inputStreamToFile(configIn, "silk-config-", ".xml");
	}
	else {
		configFile = FileUtil.inputStreamToFile(getClass().getResourceAsStream("silk-config-file.xml"), "silk-config-", ".xml");
	}
	
    // file with original data serialized in N-TRIPLE format
    File ntFile = File.createTempFile("input-rdf", ".nt");
    // file containing the equivalences
    File outFile = File.createTempFile("output-", ".nt");
    
    // update the config file with the paths of the source datasource and output files and the format
    // if the type of target datasource is "file" update the path (deduplication) 
    SilkConfigFileParser silkParser = new SilkConfigFileParser(configFile.getAbsolutePath());
    silkParser.updateOutputFile(outFile.getAbsolutePath());
    silkParser.updateSourceDataSourceFile(ntFile.getAbsolutePath(), "N-TRIPLE");
    if (silkParser.getTargetDataSourcetype().equals("file")) {
        silkParser.updateTargetDataSourceFile(ntFile.getAbsolutePath(), "N-TRIPLE"); //deduplication
    }
    silkParser.saveChanges();
    
    // change the format into N-TRIPLE
    Parser parser = Parser.getInstance();
    TripleCollection origGraph =  parser.parse(inputRdf, rdfFormat);
    Serializer serializer = Serializer.getInstance();
    serializer.serialize(new FileOutputStream(ntFile), origGraph, SupportedFormat.N_TRIPLE);

    // interlink entities
    Silk.executeFile(configFile, null, 1, true);
    log.info("Interlinking task completed."); 
    TripleCollection equivalences = parseResult(outFile); 
    
    // add the equivalence set to the input rdf data to be sent back to the client
    TripleCollection resultGraph = new SimpleMGraph();
    resultGraph.addAll(origGraph);
    resultGraph.addAll(equivalences);
    
    // remove all temporary files
    configFile.delete();        
    ntFile.delete();
    outFile.delete();

    // returns the result to the client
    return resultGraph;
}
 
开发者ID:fusepoolP3,项目名称:p3-silkdedup,代码行数:59,代码来源:DuplicatesTransformer.java


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