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

Java HDTManager类代码示例

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

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



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

示例1: createModel

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
@Override
protected Model createModel(String dbId) {
    Model model = null;
    try {
        File hdtFile = getHDTPath(dbId).toFile();
        if (hdtFile.exists()) {
            boolean useIdx = useIndex(dbId);
            String hdtFilePathStr = hdtFile.getAbsolutePath();
            logger.info(marker, "Loading '{}', useIndex={}", hdtFilePathStr, useIdx);
            HDT hdt = useIdx ? HDTManager.mapIndexedHDT(hdtFilePathStr, null) : HDTManager.loadHDT(hdtFilePathStr, null);
            HDTGraph graph = new HDTGraph(hdt);
            model = ModelFactory.createModelForGraph(graph);
            return model;
        }

       throw new FileNotFoundException("HDT file not found: '" + hdtFile + "'");

    } catch (Exception e) {
        throw new StarGraphException(e);
    }
    finally {
        if (model == null) {
            logger.error(marker, "No Graph Model instantiated for {}", dbId);
        }
    }
}
 
开发者ID:Lambda-3,项目名称:Stargraph,代码行数:27,代码来源:HDTModelFactory.java


示例2: main

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public static void main(String[] args) throws Throwable {

		// Download Semantic Web Dog Food dataset about papers and create HDT
		String url = "http://gaia.infor.uva.es/hdt/swdf-2012-11-28.hdt.gz";
		InputStream in = new BufferedInputStream(new GZIPInputStream(new URL(url).openStream()));
		try(HDT hdt = HDTManager.loadIndexedHDT(in)){
			in.close();

			// Create a Gremlin Graph
			try(HDTGraph hdtgraph = new HDTGraph(hdt)){

				// Find Mario's coauthors in SWDF dataset
				hdtgraph.traversal().V("http://data.semanticweb.org/person/mario-arias-gallego")
				.out("http://xmlns.com/foaf/0.1/made")
				.in("http://xmlns.com/foaf/0.1/made")
				.sideEffect( e-> System.out.println(e) )
				.iterate();
			}
		}
		
		System.exit(0);
	}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:23,代码来源:HDTGremlinExample.java


示例3: main

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public static void main(String[] args) throws Exception {		
		if(args.length!=2) {
			System.out.println("Usage: hdt2gremlin <file.hdt> <Gremlin Graph Config File>");
			System.out.println(" The config follows the syntax of gremlins factory Graph.open().");
			System.exit(-1);
		}
		
		// Create Graph
		Configuration p = new PropertiesConfiguration(args[1]);
		try(Graph gremlinGraph = GraphFactory.open(p)){
			
			// Open HDT
			try(HDT hdt = HDTManager.mapHDT("args[0]")){

				// Import HDT into Graph
				StopWatch st = new StopWatch();
				importGraph(hdt, gremlinGraph);
				System.out.println("Took "+st.stopAndShow());
			}
				
//			smallTest(gremlinGraph);
		}
		
		System.exit(0);
	}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:26,代码来源:HDTtoGremlin.java


示例4: LimayeGroundtruthAnnotationParser

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public LimayeGroundtruthAnnotationParser(Table table) {
		this.table = table;
		this.cellAnnotation = false;
		this.columnAnnotation = false;
		this.columnNr = 0;
		this.column = -1;
		this.row = -1;
		this.currentValue = new StringBuilder();
		HDT hdt = null;
		HDT hdt_l = null;
//		HDT hdt_d = null;
		try {
			hdt = HDTManager.mapIndexedHDT(REDIRECTS, null);
			hdt_l = HDTManager.mapIndexedHDT(LABELS, null);
//			hdt_d = HDTManager.mapIndexedHDT(TYPES, null);
		} catch (IOException e) {
			e.printStackTrace();
		}
		HDTGraph graph = new HDTGraph(hdt);
		m = ModelFactory.createModelForGraph(graph);
//		graph = new HDTGraph(hdt_d);
//		m_d = ModelFactory.createModelForGraph(graph);
		graph = new HDTGraph(hdt_l);
		m_l = ModelFactory.createModelForGraph(graph);

	}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:27,代码来源:LimayeGroundtruthAnnotationParser.java


示例5: main

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public static void main(String[] args) {
	HDT hdt = null;
	try {
		hdt = HDTManager.mapIndexedHDT(TYPES, null);
	} catch (IOException e) {
		e.printStackTrace();
	}
	
	HDTGraph graph = new HDTGraph(hdt);
	Model m = ModelFactory.createModelForGraph(graph);
	StmtIterator iter = m.listStatements();
	HashMap<String, Integer> hash = new HashMap<String, Integer>();
	int number = 0;
	while (iter.hasNext()) {
		if (number % 50000 == 0) {
			System.out.println("Processed Entries: " + number);
		}
		Statement stmt = iter.next();
		RDFNode object = stmt.getObject();
		String s = null;
		s = object.asResource().getURI();
		hash.put(s, 0);
		number++;
	}
	System.out.println("Anzahl an Typen: " +hash.size());
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:27,代码来源:CountYago2sTypes.java


示例6: main

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
@Test
// Load an HDT and perform a search. (examples/ExampleSearch.java)
public void main(String[] args) throws Exception
{
	// Load HDT file.
	// NOTE: Use loadIndexedHDT() for ?P?, ?PO or ??O queries
	HDT hdt = HDTManager.loadHDT("/media/sf_projects/experiments/hdt/raw_infobox_properties_en.hdt", null);

	// Search pattern: Empty string means "any"
	IteratorTripleString it = hdt.search("", "http://dbpedia.org/property/date", "");
	TripleString ts;
	while (it.hasNext())
	{
		ts = it.next();
		System.out.println(ts);
	}
}
 
开发者ID:emir-munoz,项目名称:ld-patterns,代码行数:18,代码来源:ExampleSearch.java


示例7: load

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
void load(String hdtDump){
    try {
        hdt = HDTManager.mapIndexedHDT(hdtDump, null);
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:WDAqua,项目名称:PageRankRDF,代码行数:8,代码来源:PageRankHDT.java


示例8: MainEvaluation

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public MainEvaluation(String maindir) {
	File maind = new File(maindir);
	HDT redirectsHDT;
	try {
		redirectsHDT = HDTManager.mapIndexedHDT("/home/quh/dbpedia_redirects.hdt", null);
		final HDTGraph redirectsHDTgraph = new HDTGraph(redirectsHDT);
		this.redirects = ModelFactory.createModelForGraph(redirectsHDTgraph);
	} catch (IOException e) {
		e.printStackTrace();
	}
	evaluate(maind);
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:13,代码来源:MainEvaluation.java


示例9: CreateDBPediaIndex

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
CreateDBPediaIndex() {
	super();
	this.LABELS = new HashMap<String, HashSet<String>>();
	this.UNIQUELABELSTRINGS = new HashMap<String, HashSet<String>>();
	this.OCCURRENCES = new HashMap<String, HashMap<String, Integer>>();
	this.relationmap = new HashMap<String, LinkedList<String>>();
	this.pattymap = new HashMap<String, LinkedList<String>>();
	this.pattyfreebasemap = new HashMap<String, LinkedList<String>>();
	this.evidencemap = new HashMap<String, HashSet<String>>();
	HDT labelhdt;
	HDT shortdeschdt;
	HDT longdeschdt;
	try {
		labelhdt = HDTManager.mapIndexedHDT(LABELHDT, null);
		shortdeschdt = HDTManager.mapIndexedHDT(SHORTDESCHDT, null);
		longdeschdt = HDTManager.mapIndexedHDT(LONGDESCHDT, null);
		final HDTGraph labelhdtgraph = new HDTGraph(labelhdt);
		final HDTGraph shortdeschdtgraph = new HDTGraph(shortdeschdt);
		final HDTGraph longdeschdtgraph = new HDTGraph(longdeschdt);
		this.labelmodel = ModelFactory.createModelForGraph(labelhdtgraph);
		this.shortdescmodel = ModelFactory
				.createModelForGraph(shortdeschdtgraph);
		this.longdescmodel = ModelFactory
				.createModelForGraph(longdeschdtgraph);
	} catch (IOException e) {
		e.printStackTrace();
	}
	this.counter = 0;
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:30,代码来源:CreateDBPediaIndex.java


示例10: Test1

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public Test1() {
	HDT mappingbasedproperties;
	try {
		mappingbasedproperties = HDTManager.mapIndexedHDT(
				MAPPINGPROPERTIESHDT, null);
		final HDTGraph instancemappingtypesgraph = new HDTGraph(
				mappingbasedproperties);
		this.mappingbasedproperties = ModelFactory
				.createModelForGraph(instancemappingtypesgraph);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:14,代码来源:Test1.java


示例11: setUpClass

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
/**
 *
 * @throws Exception
 */
@BeforeClass
public static void setUpClass() throws Exception {
    final String typeName = "HdtTestSourceType";
    if ( ! DataSourceTypesRegistry.isRegistered(typeName) ) {
        DataSourceTypesRegistry.register( typeName, new HdtDataSourceType() );
    }

    // HDT does not seem to support an InputReader, so write to temp file
    File temp = getResourceAsFile();

    HDT mgr = HDTManager.generateHDT(temp.getAbsolutePath(),
                    "http://linkeddatafragments.org",
                    RDFNotation.NTRIPLES, new HDTSpecification(), null);
    hdtfile = File.createTempFile("ldf-hdt-test", ".hdt");
    mgr.saveToHDT(hdtfile.getAbsolutePath(), null);
    
    temp.getAbsoluteFile().delete();
    
    // Everything is in place, now create the LDF datasource
    JsonObject config = createConfig("hdt test", "hdt test", typeName);
    
    JsonObject settings = new JsonObject();
    settings.addProperty("file", hdtfile.getAbsolutePath());
    config.add("settings", settings);
    
    setDatasource(DataSourceFactory.create(config));
}
 
开发者ID:LinkedDataFragments,项目名称:Server.Java,代码行数:32,代码来源:HdtDataSourceTest.java


示例12: HDTGraph

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public HDTGraph(String hdtFile) throws IOException {
	this.rawGraph = HDTManager.mapIndexedHDT(hdtFile, null);
	this.weLoaded=true;
	populateInternal();
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:6,代码来源:HDTGraph.java


示例13: action

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public void action() {
	HDT hdt = null;
	HDT hdt_l = null;
	HDT hdt_d = null;
	Model m = null;
	Model m_l = null;
	Model m_d = null;
	try {
		hdt = HDTManager.mapIndexedHDT(REDIRECTS, null);
		hdt_l = HDTManager.mapIndexedHDT(LABELS, null);
		// hdt_d = HDTManager.mapIndexedHDT(TYPES, null);
	} catch (IOException e) {
		e.printStackTrace();
	}
	HDTGraph graph = new HDTGraph(hdt);
	m = ModelFactory.createModelForGraph(graph);
	graph = new HDTGraph(hdt_l);
	m_l = ModelFactory.createModelForGraph(graph);
	File file = new File("/home/quh/Arbeitsfläche/Table Disambiguation Data sets/LimayeAll/all_tables_raw(regen)/");
	File[] f = file.listFiles();
	int cellsOverall = 0;
	int cellsAnnotated = 0;

	for (int u = 0; u < f.length; u++) {
		// System.out.println(f[u].getAbsolutePath());
		StartEvaluationTableEntities eval = new StartEvaluationTableEntities();
		String sourcePath = f[u].getAbsolutePath();

		Table t = eval.readTable(f[u].getAbsolutePath(), m, m_l, m_d);
		if (t != null) {
			int cols = t.getNumberofColumns();
			for (int i = 0; i < cols; i++) {
				Column col = t.getColumn(i);
				List<Cell> cellL = col.getCellList();
				List<String> types = col.getMajorTypes();
				cellsOverall++;
				// if(types != null && types.size() > 0) {
				// cellsAnnotated++;
				// }
				for (Cell c : cellL) {
					cellsOverall++;
					if (c.getGt() != null && !c.getGt().equalsIgnoreCase("")) {
						cellsAnnotated++;
					}
				}
			}

			System.out.println("Zellen insgesamt: " + cellsOverall + " Zellen annotiert: " + cellsAnnotated);

			// Query each column separately
			for (int i = 0; i < t.getNumberofColumns(); i++) {
				Column column = t.getColumn(i);
				List<EntityDisambiguationDPO> request_dpo = eval.transformInRequestFormat(column);
				String topic = column.getHeader();
				List<Response> l = queryService(request_dpo, topic);
				setDisambiguatedColumn(t, i, l);
			}

			StartEvaluationTableEntities.evaluateResults(t);
		}
	}
	System.out.println("Insgesamt: " + sum + " davon richtig: " + correct);
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:64,代码来源:StartEvaluationTableEntities.java


示例14: CreateDBpediaIndexV2

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public CreateDBpediaIndexV2() {
	super();
	this.relationmap = new HashMap<String, LinkedList<String>>();
	this.pattymap = new HashMap<String, LinkedList<String>>();
	this.pattyfreebasemap = new HashMap<String, LinkedList<String>>();

	this.OCCURRENCES = new HashMap<String, HashMap<String, Integer>>();

	this.LABELS = new HashMap<String, HashSet<String>>();
	this.UNIQUELABELSTRINGS = new HashMap<String, HashSet<String>>();
	this.DBPEDIAGRAPHINLINKS = new HashMap<String, Integer>();
	this.evidences = new HashMap<String, String>();
	this.teams = new HashSet<String>();

	this.urlentitymapping = new HashMap<String, String>();

	this.entities = new HashSet<String>();

	this.counter = 0;

	HDT labelhdt;
	HDT shortdeschdt;
	HDT longdeschdt;
	HDT mappingbasedproperties;
	HDT instancemappingtypeshdt;
	try {
		labelhdt = HDTManager.mapIndexedHDT(LABELHDT, null);
		shortdeschdt = HDTManager.mapIndexedHDT(SHORTDESCHDT, null);
		longdeschdt = HDTManager.mapIndexedHDT(LONGDESCHDT, null);
		mappingbasedproperties = HDTManager.mapIndexedHDT(PERSONDATAHDT, null);
		instancemappingtypeshdt = HDTManager.mapIndexedHDT(INSTANCEMAPPINGTYPES, null);
		final HDTGraph labelhdtgraph = new HDTGraph(labelhdt);
		final HDTGraph shortdeschdtgraph = new HDTGraph(shortdeschdt);
		final HDTGraph longdeschdtgraph = new HDTGraph(longdeschdt);
		final HDTGraph instancepersondata = new HDTGraph(mappingbasedproperties);
		final HDTGraph instancemappingtypesgraph = new HDTGraph(instancemappingtypeshdt);
		this.labelmodel = ModelFactory.createModelForGraph(labelhdtgraph);
		this.shortdescmodel = ModelFactory.createModelForGraph(shortdeschdtgraph);
		this.longdescmodel = ModelFactory.createModelForGraph(longdeschdtgraph);
		this.persondata = ModelFactory.createModelForGraph(instancepersondata);
		this.instancemappingtypes = ModelFactory.createModelForGraph(instancemappingtypesgraph);
	} catch (IOException e) {
		e.printStackTrace();
	}
}
 
开发者ID:quhfus,项目名称:DoSeR,代码行数:46,代码来源:CreateDBpediaIndexV2.java


示例15: readHDT

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public static MapDTGraph<String, String> readHDT(File file) 
	throws FileNotFoundException, IOException
{
	MapDTGraph<String, String> graph = new MapDTGraph<String, String>();
	
	HDT hdt = HDTManager.loadHDT(
			new BufferedInputStream(new FileInputStream(file)), null);

	int i = 0;
	try {
		// Search pattern: Empty string means "any"
		IteratorTripleString it = hdt.search("", "", "");
		DTNode<String, String> node1, node2;
					
		while(it.hasNext()) {
			TripleString ts = it.next();

			String subject = ts.getSubject().toString(), 
			       predicate = ts.getPredicate().toString(),
			       object = ts.getObject().toString();
			
			node1 = graph.node(subject);
			node2 = graph.node(object);
		
			if (node1 == null) 
				node1 = graph.add(subject);
	
			
			if (node2 == null) 
				node2 = graph.add(object);
							
			node1.connect(node2, predicate);
			
			Functions.dot(i, (int)it.estimatedNumResults());
			i++;
		}
	} catch (NotFoundException e) 
	{
		// File must be empty, return empty graph
	} finally 
	{
		// IMPORTANT: Free resources
		hdt.close();
	}
	
	return graph;
}
 
开发者ID:Data2Semantics,项目名称:nodes,代码行数:48,代码来源:RDF.java


示例16: readSimpleHDT

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
public static UGraph<String> readSimpleHDT(File file, List<String> whiteList)
		throws IOException
{	
	List<Pattern> patterns = whiteList != null ? toPatterns(whiteList) : null;
	
	final UGraph<String> graph = new LightUGraph<String>();
	final Map<String, UNode<String>> nodes = new HashMap<String, UNode<String>>();
	
	HDT hdt = HDTManager.loadHDT(
			new BufferedInputStream(new FileInputStream(file)), null);

	// Search pattern: Empty string means "any"
	IteratorTripleString it;
	try
	{
		it = hdt.search("", "", "");
	} catch (NotFoundException e)
	{
		throw new RuntimeException(e);
	}

	DTNode<String, String> node1, node2;
			
	
	Global.log().info("Start loading graph: " + it.estimatedNumResults() + " triples (estimated).");
	
	long read = 0;
	tic();
	while(it.hasNext()) 
	{
		TripleString ts = it.next();

		String predicate = ts.getPredicate().toString();
		
		if(patterns == null || matches(predicate, patterns))
		{
   			String subject = ts.getSubject().toString();
   			String object = ts.getObject().toString();
   			
   			subject = UnicodeEscape.unescapeString(subject);
   			if(! object.startsWith("\""))
   				object  = UnicodeEscape.unescapeString(object);
   				
   			if(! nodes.containsKey(subject))
   				nodes.put(subject, graph.add(subject));
   			if(! nodes.containsKey(object))
   				nodes.put(object, graph.add(object));
   				
   			UNode<String> subNode = nodes.get(subject); 
   			UNode<String> obNode = nodes.get(object);
   			
   			if( (!subNode.connected(obNode)) &&  subNode.index() != obNode.index() )
   				subNode.connect(obNode);
		}
		
		if(toc() > 600)
		{
			Global.log().info("Reading graph in progress: " + graph.size() + " nodes, " + graph.numLinks() + " links added so far. " + read + " triples read.");
			tic();
		}
		read++;
	}
	
	Global.log().info("Graph read.");

	return graph;
}
 
开发者ID:Data2Semantics,项目名称:nodes,代码行数:68,代码来源:RDF.java


示例17: HdtBasedRequestProcessorForTPFs

import org.rdfhdt.hdt.hdt.HDTManager; //导入依赖的package包/类
/**
 * Creates the request processor.
 *
 * @param hdtFile the HDT datafile
 * @throws IOException if the file cannot be loaded
 */
public HdtBasedRequestProcessorForTPFs( String hdtFile ) throws IOException
{
    datasource = HDTManager.mapIndexedHDT( hdtFile, null ); // listener=null
    dictionary = new NodeDictionary( datasource.getDictionary() );
}
 
开发者ID:LinkedDataFragments,项目名称:Server.Java,代码行数:12,代码来源:HdtBasedRequestProcessorForTPFs.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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