本文整理汇总了Java中com.tinkerpop.blueprints.impls.tg.TinkerGraph.createIndex方法的典型用法代码示例。如果您正苦于以下问题:Java TinkerGraph.createIndex方法的具体用法?Java TinkerGraph.createIndex怎么用?Java TinkerGraph.createIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.tinkerpop.blueprints.impls.tg.TinkerGraph
的用法示例。
在下文中一共展示了TinkerGraph.createIndex方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEisteinClause
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testEisteinClause() throws Exception {
TinkerGraph graph = new TinkerGraph();
graph.createIndex("verb-idx", Vertex.class);
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
Vertex c = graph.addVertex(null);
Vertex d = graph.addVertex(null);
a.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein");
a.setProperty("ner", "PERSON");
a.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
b.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm");
b.setProperty("ner", "PERSON");
b.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
c.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
c.setProperty("ner", "PERSON");
c.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
d.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born");
d.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
}
示例2: setup
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
graph = new TinkerGraph();
graph.createIndex("verb-idx", Vertex.class);
/* Add extractions to graph */
// exact answer
NerdleFact extraction = new NerdleFact(
"Einstein was born in Ulm on 4th May.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was born", ""));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("in Ulm", "L"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// one argument missing
extraction = new NerdleFact("Einstein was born in Ulm.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was born", ""));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("in Ulm", "L"));
NerdleGraphTransformer.transform(extraction, graph);
// one argument missing
extraction = new NerdleFact("Einstein was born on 4th May.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was born", ""));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// different
extraction = new NerdleFact("Groblen was captain of Troika.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was captain", ""));
extraction.setSubject(new NerdleSubject("Groblen"));
extraction.addArgument(new NerdleArg("of Troika","T"));
NerdleGraphTransformer.transform(extraction, graph);
// different
extraction = new NerdleFact("Groblen attacked star strek caption of Andria.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("attacked", ""));
extraction.setSubject(new NerdleSubject("Groblen"));
extraction.addArgument(new NerdleArg("star strek caption of Andria", "T"));
NerdleGraphTransformer.transform(extraction, graph);
}
示例3: testMultipleClauses
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@Test
public void testMultipleClauses() throws Exception {
TinkerGraph graph = new TinkerGraph();
graph.createIndex("verb-idx", Vertex.class);
Vertex a = graph.addVertex(null);
Vertex b = graph.addVertex(null);
Vertex c = graph.addVertex(null);
Vertex d = graph.addVertex(null);
a.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein");
a.setProperty("ner", "PERSON");
a.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
b.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm");
b.setProperty("ner", "PERSON");
b.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
c.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
c.setProperty("ner", "PERSON");
c.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
d.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born");
d.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
graph.addEdge(null, d, a, "");
graph.addEdge(null, d, b, "");
graph.addEdge(null, d, c, "");
Vertex aX = graph.addVertex(null);
Vertex bX = graph.addVertex(null);
Vertex cX = graph.addVertex(null);
Vertex dX = graph.addVertex(null);
aX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"Einstein X");
aX.setProperty("ner", "PERSON");
aX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_SUBJECT);
bX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"in Ulm X");
bX.setProperty("ner", "PERSON");
bX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
cX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"on 4th May");
cX.setProperty("ner", "PERSON X");
cX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_ARGUMENT);
dX.setProperty(NerdleGraphTransformer.PROPERTY_TEXT,"was born X");
dX.setProperty("clause_type", NerdleGraphTransformer.VALUE_CLAUSE_TYPE_PREDICATE);
graph.addEdge(null, dX, aX, "");
graph.addEdge(null, dX, bX, "");
graph.addEdge(null, dX, cX, "");
}
示例4: setup
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
graph = new TinkerGraph();
graph.createIndex("verb-idx", Vertex.class);
/* Add extractions to graph */
// exact answer
NerdleFact extraction = new NerdleFact(
"Einstein was born in Ulm on 4th May.", "", 0.8D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("in Ulm", "L"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// exact answer
extraction = new NerdleFact("Einstein was a professor.", "", 0.0D);
extraction.setPredicate(new NerdlePredicate("was", "be"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("a professor", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// false answer
extraction = new NerdleFact("Leibnitz was a professor.", "", 0.0D);
extraction.setPredicate(new NerdlePredicate("was", "be"));
extraction.setSubject(new NerdleSubject("Leibnitz"));
extraction.addArgument(new NerdleArg("a professor", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// false answer
extraction = new NerdleFact("Gauss was born in Berlin on 4th May.", "",
0.5D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Gauss"));
extraction.addArgument(new NerdleArg("in Berlin", "L"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// false answer
extraction = new NerdleFact("Gauss was a professor.", "", 0.0D);
extraction.setPredicate(new NerdlePredicate("was", "be"));
extraction.setSubject(new NerdleSubject("Gauss"));
extraction.addArgument(new NerdleArg("a professor", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// one argument missing
extraction = new NerdleFact("Einstein was born in Ulm.", "", 0.6D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("in Ulm", "L"));
NerdleGraphTransformer.transform(extraction, graph);
// one argument missing
extraction = new NerdleFact("Einstein was born on 4th May.", "", 0.4D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
}
示例5: setup
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
@BeforeClass
public static void setup() {
graph = new TinkerGraph();
graph.createIndex("verb-idx", Vertex.class);
/* Add extractions to graph */
// exact answer
NerdleFact extraction = new NerdleFact(
"Einstein was born in Ulm on 4th May.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("in Ulm", "L"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// exact answer
extraction = new NerdleFact("Einstein was a professor.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was", "be"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("a professor", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// false answer
extraction = new NerdleFact("Leibnitz was a professor.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was", "be"));
extraction.setSubject(new NerdleSubject("Leibnitz"));
extraction.addArgument(new NerdleArg("a professor", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// false answer
extraction = new NerdleFact("Gauss was born in Berlin on 4th May.", "",
0.5D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Gauss"));
extraction.addArgument(new NerdleArg("in Berlin", "L"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// false answer
extraction = new NerdleFact("Gauss was a professor.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was", "be"));
extraction.setSubject(new NerdleSubject("Gauss"));
extraction.addArgument(new NerdleArg("a professor", "T"));
NerdleGraphTransformer.transform(extraction, graph);
// one argument missing
extraction = new NerdleFact("Einstein was born in Ulm.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("in Ulm", "L"));
NerdleGraphTransformer.transform(extraction, graph);
// one argument missing
extraction = new NerdleFact("Einstein was born on 4th May.", "", 0.5D);
extraction.setPredicate(new NerdlePredicate("was born", "bear"));
extraction.setSubject(new NerdleSubject("Einstein"));
extraction.addArgument(new NerdleArg("on 4th May", "T"));
NerdleGraphTransformer.transform(extraction, graph);
}
示例6: buildGraph
import com.tinkerpop.blueprints.impls.tg.TinkerGraph; //导入方法依赖的package包/类
public static Graph buildGraph() {
TinkerGraph graph = new TinkerGraph("/tmp/cfggraph", TinkerGraph.FileType.GRAPHML);
graph.createIndex("signatureName", Vertex.class);
graph.createIndex("sha256", Vertex.class);
graph.createIndex("md5", Vertex.class);
graph.createIndex("type", Vertex.class);
Map sigLookup = new HashMap<String, Vertex>();
Map fileLookup = new HashMap<String, Vertex>();
for(Match match : matches) {
// check map for sig
CFGSig matchSig = match.getSignature();
String sigString = matchSig.getStringSignature();
Vertex sigVertex = (Vertex)sigLookup.get(sigString);
if(sigVertex == null) {
// create vertex
sigVertex = graph.addVertex(null);
sigVertex.setProperty("type", "signature");
sigVertex.setProperty("signature", sigString);
sigVertex.setProperty("signatureName", matchSig.getName());
// add sig to map
sigLookup.put(sigString, sigVertex);
}
// check map for file
String fileSHA256 = match.getFileSHA256();
Vertex fileVertex = (Vertex)fileLookup.get(fileSHA256);
if(fileVertex == null) {
// create vertex
fileVertex = graph.addVertex(null);
sigVertex.setProperty("type", "file");
fileVertex.setProperty("sha256", fileSHA256);
fileVertex.setProperty("md5", match.getFileMD5());
fileVertex.setProperty("fileNameList", new ArrayList<String>());
// add file to map
fileLookup.put(fileSHA256, fileVertex);
}
// what idiot would scan the same file multiple times with different names?
List<String> fileNames = fileVertex.getProperty("fileNameList");
if(!fileNames.contains(match.getFileName())) {
fileNames.add(match.getFileName());
}
// TODO: comment this out and see if it still works
fileVertex.setProperty("fileNameList", fileNames);
// create edge(sig, file)
Edge matchEdge = graph.addEdge(null, sigVertex, fileVertex, "matches");
ControlFlowGraph cfg = match.getControlFlowGraph();
matchEdge.setProperty("method", cfg.getIdentifier(false));
// matchEdge.setProperty("fileBytes", cfg.getMethodBytesAsHexString());
}
return graph;
}