2

我想为特定的故事情节构建一个知识图谱,因此我(S,P,O)使用 OpenIE 提取了关系三元组。现在我想从这些我不知道该怎么做的关系三元组创建图形数据库。所以这是我的问题:
1)我应该使用哪个图形数据库,为什么?
2)如何从关系三元组创建数据库,或者是否可以从原始关系三元组在任何图形数据库中创建关系图?

例如,假设我选择Neo4j图形数据库:
关系三元组看起来像:['Barack Obama', ' was born in', ' Hawaii']
如何以编程方式创建 Neo4j 图形['Barack Obama', ' was born in', ' Hawaii']

Barak Obama and HawaiiNodes
was born inRelationship

4

1 回答 1

2

使用 OrientDB 你可以这样做:

create class Person extends V
create property Person.name string
create property Person.surname string
insert into Person(name, surname) values ("Barack","Obama")

create class Country extends V
create property Country.name string
insert into Country(name) values ("Hawaii")

create class was_born_in extends E

create edge was_born_in from (select from Person where name = "Barack") to (select from Country where name = "Hawaii")

这是这种情况:

+----+-----+-------+------+-------+---------------+--------------+
|#   |@RID |@CLASS |name  |surname|out_was_born_in|in_was_born_in|
+----+-----+-------+------+-------+---------------+--------------+
|0   |#17:0|Person |Barack|Obama  |[#25:0]        |              |
|1   |#21:0|Country|Hawaii|       |               |[#25:0]       |
+----+-----+-------+------+-------+---------------+--------------+

如果您运行此查询:

select expand(in('was_born_in')) from Country where name = "Hawaii"

你会得到所有住在夏威夷的人

+----+-----+------+------+-------+---------------+
|#   |@RID |@CLASS|name  |surname|out_was_born_in|
+----+-----+------+------+-------+---------------+
|0   |#17:0|Person|Barack|Obama  |[#25:0]        |
+----+-----+------+------+-------+---------------+

希望能帮助到你

问候

于 2018-01-23T01:33:15.537 回答