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


Java HDT类代码示例

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


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

示例1: createModel

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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: label

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的package包/类
static void label(WikidataQ wikidataQ) throws NotFoundException {

        Map<String, HDT> l = getMap();

        for (String lang : l.keySet()) {
            if(lang.equalsIgnoreCase("wikidata")){
                continue;
            }
            HDT hdt = l.get(lang);

            // Search pattern: Empty string means "any"
            try {
                IteratorTripleString it = hdt.search(wikidataQ.URI, "http://www.w3.org/2000/01/rdf-schema#label", "");
                while (it.hasNext()) {
                    TripleString ts = it.next();
                    wikidataQ.labels.add(ts.getObject().toString());
                }
            } catch (NotFoundException nfe) {
                //intentionally left blank.
                //hdt.search should return null, not an NF exception
            }
        }

    }
 
开发者ID:dbpedia,项目名称:fusion,代码行数:25,代码来源:HDTFusion.java

示例3: main

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例4: main

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例5: LimayeGroundtruthAnnotationParser

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例6: main

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例7: main

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例8: importGraph

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的package包/类
private static void importGraph(HDT hdt, Graph graph) {
		
		Dictionary d = hdt.getDictionary();
		
		long [] sharedMap = new long[(int)d.getNshared()];
		long [] subjectMap = new long[(int)(d.getNsubjects()-d.getNshared())];
//		long [] predicateMap = new long[(int)d.getNpredicates()];
		long [] objectMap = new long[(int)(d.getNobjects()-d.getNshared())];
		
//		load(predicateMap, d.getPredicates().getSortedEntries(), to);
		loadSection(sharedMap, d.getShared().getSortedEntries(), graph, DictionarySectionRole.SHARED);
		loadSection(subjectMap, d.getSubjects().getSortedEntries(), graph, DictionarySectionRole.SUBJECT);
		loadSection(objectMap, d.getObjects().getSortedEntries(), graph, DictionarySectionRole.OBJECT);
		
		IteratorTripleID it = hdt.getTriples().searchAll();
		
		int count=0;
		while(it.hasNext()) {
			TripleID triple = it.next();
			long s = getIDShared(sharedMap, subjectMap, triple.getSubject());
//			long p = predicateMap[triple.getPredicate()-1];
			long o = getIDShared(sharedMap, objectMap, triple.getObject());
			
			Vertex subj = graph.vertices(s).next();
			Vertex obj = graph.vertices(o).next();
			
			subj.addEdge(d.idToString(triple.getPredicate(), TripleComponentRole.PREDICATE).toString(), obj);
			
			if((count%10000)==0) {
				System.out.println("Edges: "+(count/1000)+"K");
			}
			count++;
		}
	}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:35,代码来源:HDTtoGremlin.java

示例9: MainEvaluation

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例10: CreateDBPediaIndex

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例11: Test1

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例12: setUpClass

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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

示例13: PageRankHDT

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的package包/类
public PageRankHDT(HDT hdt, double dampingFactor, double startValue, int numberOfIterations){
    this.hdt = hdt;
    this.dampingFactor = dampingFactor;
    this.startValue = startValue;
    this.numberOfIterations = numberOfIterations;
}
 
开发者ID:WDAqua,项目名称:PageRankRDF,代码行数:7,代码来源:PageRankHDT.java

示例14: HDTGraph

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

示例15: getBaseGraph

import org.rdfhdt.hdt.hdt.HDT; //导入依赖的package包/类
@Override
public HDT getBaseGraph() {
	return rawGraph;
}
 
开发者ID:rdfhdt,项目名称:hdt-gremlin,代码行数:5,代码来源:HDTGraph.java


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