本文整理汇总了Java中org.rdfhdt.hdt.hdt.HDT类的典型用法代码示例。如果您正苦于以下问题:Java HDT类的具体用法?Java HDT怎么用?Java HDT使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HDT类属于org.rdfhdt.hdt.hdt包,在下文中一共展示了HDT类的19个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: action
import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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
示例17: CreateDBpediaIndexV2
import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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
示例18: readHDT
import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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
示例19: readSimpleHDT
import org.rdfhdt.hdt.hdt.HDT; //导入依赖的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
注:本文中的org.rdfhdt.hdt.hdt.HDT类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论