密码查询叉子图案

时间:2019-06-25 00:21:18

标签: neo4j nlp cypher token

我正在尝试查询单词图上的关系,该图的关系是哪个单词在下一个单词之前。我想查询一种模式,该模式看起来像图中的叉子或Y,在这对模式中有一对常见的顺序词,后面有两个不同的词。例如,在创世纪1上的图表中,我可能想查询短语“ over every”后面的成对的不同单词,然后可以是“ living”或“ creeping”。

与其返回短语后面的所有单词,不如将两个不同的单词都返回到同一记录中会更好。该查询的目的是将生存和爬行之间的隐式关系显示为“同级”单词,如果以这种方式一起返回,将会更容易。

我最初的想法是对短语后面的单词模式进行两次匹配,然后将它们结合在一起以合并不同的单词。但是我希望有一种我不知道的更直接的方法。是否存在?enter image description here

修改

示例查询可帮助您了解这个主意:

MATCH
    (o {text: "OVER"})-[:BEFORE]->(e {text: "EVERY"})-[:BEFORE]->(t), 
    (o)-[:BEFORE]->(e)-[:BEFORE]->(c)
CREATE (l)-[:SIBLING]->(c)

2 个答案:

答案 0 :(得分:0)

单词集合呢?

我将在此处使用:Word添加标签(您应该使用标签,并在可能的情况下使用索引)

MATCH
    (o:Word {text: "OVER"})-[:BEFORE]->(e:Word {text: "EVERY"})-[:BEFORE]->(next)
RETURN collect(next.text) as nextWords

答案 1 :(得分:0)

accepted answer中的What does a comma in a Cypher query do?比我最初的方法要近一些。这涉及到使用逗号来实现模式中的派生,因此要取代上面的MATCH子句

MATCH
    (o {text: "OVER"})-[:BEFORE]->(e {text: "EVERY"})-[:BEFORE]->(t), 
    (o)-[:BEFORE]->(e)-[:BEFORE]->(c)

我会做

MATCH
    (o {text: "OVER"})-[:BEFORE]->(e {text: "EVERY"})-[:BEFORE]->(t), 
    (e)-[:BEFORE]->(c)

无需重新匹配(o)-[:BEFORE]->(e)

使用第二个MATCH子句确实为我提供了我尝试匹配的fork模式,但是结果缺少适当的上下文级别-而不是返回短语“ OVER EVERY”之后的所有单词,它只是返回“每个”之后的所有单词。经过进一步的思考,这是有道理的,因为这确实是我要它做的。匹配“ OVER”,“ EVERY”和“ EVERY”之后的两个单词。我在图表中的唯一上下文是哪个单词跟随哪个单词。没有关于哪个词跟哪个短语的上下文。

要解决此问题,我最终重新制作了图形,并为其提供了完整的短语上下文。原始图模型仅包含文档中所有唯一词的节点,并且每个唯一词之间的关系相互关联-对于简单的双角马尔可夫树而言,好的数据,对于较长的n角而言,则不好。新的图形模型仍然包含代表文档唯一词的一组节点,以及代表每个单独词的另一组节点。各个单词按照它们在文档中出现的顺序相互关联,最终看起来像一长串的单词节点。唯一词的相关性在于,这是一个具有三个词节点长的通用短语的叉子的同胞。有了适当的短语上下文,我便能够获得我原本想要的同级关系。

代码

原始模型

唯一词节点(样本):

CREATE (CommaChar:Token {text:','})
CREATE (PeriodChar:Token {text:'.'})
CREATE (ColonChar:Token {text:':'})
CREATE (SemicolonChar:Token {text:';'})
CREATE (A:Token {text:'A'})
CREATE (Above:Token {text:'ABOVE'})
CREATE (Abundantly:Token {text:'ABUNDANTLY'})
CREATE (After:Token {text:'AFTER'})
CREATE (Air:Token {text:'AIR'})
CREATE (All:Token {text:'ALL'})
CREATE (Also:Token {text:'ALSO'})
CREATE (And:Token {text:'AND'})
CREATE (Appear:Token {text:'APPEAR'})
CREATE (Be:Token {text:'BE'})
CREATE (Bearing:Token {text:'BEARING'})
...
CREATE (Whales:Token {text:'WHALES'})
CREATE (Wherein:Token {text:'WHEREIN'})
CREATE (Which:Token {text:'WHICH'})
CREATE (Whose:Token {text:'WHOSE'})
CREATE (Winged:Token {text:'WINGED'})
CREATE (Without:Token {text:'WITHOUT'})
CREATE (Years:Token {text:'YEARS'})
CREATE (Yielding:Token {text:'YIELDING'})
CREATE (You:Token {text:'YOU'})

BEFORE关系:

CREATE (PhraseStart)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Beginning)-[:BEFORE]->(God)-[:BEFORE]->(Created)-[:BEFORE]->(The)-[:BEFORE]->(Heaven)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(Was)-[:BEFORE]->(Without)-[:BEFORE]->(Form)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Void)-[:BEFORE]->(SemicolonChar)-[:BEFORE]->(And)-[:BEFORE]->(Darkness)-[:BEFORE]->(Was)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Face)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Deep)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Spirit)-[:BEFORE]->(Of)-[:BEFORE]->(God)-[:BEFORE]->(Moved)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Face)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(There)-[:BEFORE]->(Be)-[:BEFORE]->(Light)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(There)-[:BEFORE]->(Was)-[:BEFORE]->(Light)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(The)-[:BEFORE]->(Light)-[:BEFORE]->(CommaChar)-[:BEFORE]->(That)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Good)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Divided)-[:BEFORE]->(The)-[:BEFORE]->(Light)-[:BEFORE]->(From)-[:BEFORE]->(The)-[:BEFORE]->(Darkness)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Called)-[:BEFORE]->(The)-[:BEFORE]->(Light)-[:BEFORE]->(Day)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Darkness)-[:BEFORE]->(He)-[:BEFORE]->(Called)-[:BEFORE]->(Night)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Evening)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Morning)-[:BEFORE]->(Were)-[:BEFORE]->(The)-[:BEFORE]->(First)-[:BEFORE]->(Day)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(There)-[:BEFORE]->(Be)-[:BEFORE]->(A)-[:BEFORE]->(Firmament)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Midst)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Let)-[:BEFORE]->(It)-[:BEFORE]->(Divide)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(From)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Made)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Divided)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(Which)-[:BEFORE]->(Were)-[:BEFORE]->(Under)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(From)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(Which)-[:BEFORE]->(Were)-[:BEFORE]->(Above)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(So)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Called)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(Heaven)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Evening)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Morning)-[:BEFORE]->(Were)-[:BEFORE]->(The)-[:BEFORE]->(Second)-[:BEFORE]->(Day)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(Under)-[:BEFORE]->(The)-[:BEFORE]->(Heaven)-[:BEFORE]->(Be)-[:BEFORE]->(Gathered)-[:BEFORE]->(Together)-[:BEFORE]->(Unto)-[:BEFORE]->(One)-[:BEFORE]->(Place)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Let)-[:BEFORE]->(The)-[:BEFORE]->(Dry)-[:BEFORE]->(Land)-[:BEFORE]->(Appear)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(So)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Called)-[:BEFORE]->(The)-[:BEFORE]->(Dry)-[:BEFORE]->(Land)-[:BEFORE]->(Earth)-[:BEFORE]->(SemicolonChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Gathering)-[:BEFORE]->(Together)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(Called)-[:BEFORE]->(He)-[:BEFORE]->(Seas)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(That)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Good)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(Bring)-[:BEFORE]->(Forth)-[:BEFORE]->(Grass)-[:BEFORE]->(CommaChar)-[:BEFORE]->(The)-[:BEFORE]->(Herb)-[:BEFORE]->(Yielding)-[:BEFORE]->(Seed)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Fruit)-[:BEFORE]->(Tree)-[:BEFORE]->(Yielding)-[:BEFORE]->(Fruit)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Whose)-[:BEFORE]->(Seed)-[:BEFORE]->(Is)-[:BEFORE]->(In)-[:BEFORE]->(Itself)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(So)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(Brought)-[:BEFORE]->(Forth)-[:BEFORE]->(Grass)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Herb)-[:BEFORE]->(Yielding)-[:BEFORE]->(Seed)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Tree)-[:BEFORE]->(Yielding)-[:BEFORE]->(Fruit)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Whose)-[:BEFORE]->(Seed)-[:BEFORE]->(Was)-[:BEFORE]->(In)-[:BEFORE]->(Itself)-[:BEFORE]->(CommaChar)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(That)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Good)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Evening)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Morning)-[:BEFORE]->(Were)-[:BEFORE]->(The)-[:BEFORE]->(Third)-[:BEFORE]->(Day)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(There)-[:BEFORE]->(Be)-[:BEFORE]->(Lights)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Heaven)-[:BEFORE]->(To)-[:BEFORE]->(Divide)-[:BEFORE]->(The)-[:BEFORE]->(Day)-[:BEFORE]->(From)-[:BEFORE]->(The)-[:BEFORE]->(Night)-[:BEFORE]->(SemicolonChar)-[:BEFORE]->(And)-[:BEFORE]->(Let)-[:BEFORE]->(Them)-[:BEFORE]->(Be)-[:BEFORE]->(For)-[:BEFORE]->(Signs)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(For)-[:BEFORE]->(Seasons)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(For)-[:BEFORE]->(Days)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Years)-[:BEFORE]->(ColonChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(Let)-[:BEFORE]->(Them)-[:BEFORE]->(Be)-[:BEFORE]->(For)-[:BEFORE]->(Lights)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Heaven)-[:BEFORE]->(To)-[:BEFORE]->(Give)-[:BEFORE]->(Light)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(So)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Made)-[:BEFORE]->(Two)-[:BEFORE]->(Great)-[:BEFORE]->(Lights)-[:BEFORE]->(SemicolonChar)-[:BEFORE]->(The)-[:BEFORE]->(Greater)-[:BEFORE]->(Light)-[:BEFORE]->(To)-[:BEFORE]->(Rule)-[:BEFORE]->(The)-[:BEFORE]->(Day)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Lesser)-[:BEFORE]->(Light)-[:BEFORE]->(To)-[:BEFORE]->(Rule)-[:BEFORE]->(The)-[:BEFORE]->(Night)-[:BEFORE]->(ColonChar)-[:BEFORE]->(He)-[:BEFORE]->(Made)-[:BEFORE]->(The)-[:BEFORE]->(Stars)-[:BEFORE]->(Also)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Set)-[:BEFORE]->(Them)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Firmament)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Heaven)-[:BEFORE]->(To)-[:BEFORE]->(Give)-[:BEFORE]->(Light)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(To)-[:BEFORE]->(Rule)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Day)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Night)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(To)-[:BEFORE]->(Divide)-[:BEFORE]->(The)-[:BEFORE]->(Light)-[:BEFORE]->(From)-[:BEFORE]->(The)-[:BEFORE]->(Darkness)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(That)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Good)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Evening)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Morning)-[:BEFORE]->(Were)-[:BEFORE]->(The)-[:BEFORE]->(Fourth)-[:BEFORE]->(Day)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(Bring)-[:BEFORE]->(Forth)-[:BEFORE]->(Abundantly)-[:BEFORE]->(The)-[:BEFORE]->(Moving)-[:BEFORE]->(Creature)-[:BEFORE]->(That)-[:BEFORE]->(Hath)-[:BEFORE]->(Life)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Fowl)-[:BEFORE]->(That)-[:BEFORE]->(May)-[:BEFORE]->(Fly)-[:BEFORE]->(Above)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Open)-[:BEFORE]->(Firmament)-[:BEFORE]->(Of)-[:BEFORE]->(Heaven)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Created)-[:BEFORE]->(Great)-[:BEFORE]->(Whales)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Every)-[:BEFORE]->(Living)-[:BEFORE]->(Creature)-[:BEFORE]->(That)-[:BEFORE]->(Moveth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Which)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(Brought)-[:BEFORE]->(Forth)-[:BEFORE]->(Abundantly)-[:BEFORE]->(CommaChar)-[:BEFORE]->(After)-[:BEFORE]->(Their)-[:BEFORE]->(Kind)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Every)-[:BEFORE]->(Winged)-[:BEFORE]->(Fowl)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(That)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Good)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Blessed)-[:BEFORE]->(Them)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Saying)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Be)-[:BEFORE]->(Fruitful)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Multiply)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Fill)-[:BEFORE]->(The)-[:BEFORE]->(Waters)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Seas)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Let)-[:BEFORE]->(Fowl)-[:BEFORE]->(Multiply)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Evening)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Morning)-[:BEFORE]->(Were)-[:BEFORE]->(The)-[:BEFORE]->(Fifth)-[:BEFORE]->(Day)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(Bring)-[:BEFORE]->(Forth)-[:BEFORE]->(The)-[:BEFORE]->(Living)-[:BEFORE]->(Creature)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Cattle)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Creeping)-[:BEFORE]->(Thing)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Beast)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(So)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Made)-[:BEFORE]->(The)-[:BEFORE]->(Beast)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Cattle)-[:BEFORE]->(After)-[:BEFORE]->(Their)-[:BEFORE]->(Kind)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Every)-[:BEFORE]->(Thing)-[:BEFORE]->(That)-[:BEFORE]->(Creepeth)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(After)-[:BEFORE]->(His)-[:BEFORE]->(Kind)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(That)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Good)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Let)-[:BEFORE]->(Us)-[:BEFORE]->(Make)-[:BEFORE]->(Man)-[:BEFORE]->(In)-[:BEFORE]->(Our)-[:BEFORE]->(Image)-[:BEFORE]->(CommaChar)-[:BEFORE]->(After)-[:BEFORE]->(Our)-[:BEFORE]->(Likeness)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(Let)-[:BEFORE]->(Them)-[:BEFORE]->(Have)-[:BEFORE]->(Dominion)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Fish)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Sea)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Fowl)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Air)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Cattle)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(All)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(Every)-[:BEFORE]->(Creeping)-[:BEFORE]->(Thing)-[:BEFORE]->(That)-[:BEFORE]->(Creepeth)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(So)-[:BEFORE]->(God)-[:BEFORE]->(Created)-[:BEFORE]->(Man)-[:BEFORE]->(In)-[:BEFORE]->(His)-[:BEFORE]->(Own)-[:BEFORE]->(Image)-[:BEFORE]->(CommaChar)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Image)-[:BEFORE]->(Of)-[:BEFORE]->(God)-[:BEFORE]->(Created)-[:BEFORE]->(He)-[:BEFORE]->(Him)-[:BEFORE]->(SemicolonChar)-[:BEFORE]->(Male)-[:BEFORE]->(And)-[:BEFORE]->(Female)-[:BEFORE]->(Created)-[:BEFORE]->(He)-[:BEFORE]->(Them)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Blessed)-[:BEFORE]->(Them)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(Unto)-[:BEFORE]->(Them)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Be)-[:BEFORE]->(Fruitful)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Multiply)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Replenish)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Subdue)-[:BEFORE]->(It)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(Have)-[:BEFORE]->(Dominion)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Fish)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Sea)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(The)-[:BEFORE]->(Fowl)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Air)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Over)-[:BEFORE]->(Every)-[:BEFORE]->(Living)-[:BEFORE]->(Thing)-[:BEFORE]->(That)-[:BEFORE]->(Moveth)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Said)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Behold)-[:BEFORE]->(CommaChar)-[:BEFORE]->(I)-[:BEFORE]->(Have)-[:BEFORE]->(Given)-[:BEFORE]->(You)-[:BEFORE]->(Every)-[:BEFORE]->(Herb)-[:BEFORE]->(Bearing)-[:BEFORE]->(Seed)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Which)-[:BEFORE]->(Is)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Face)-[:BEFORE]->(Of)-[:BEFORE]->(All)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(Every)-[:BEFORE]->(Tree)-[:BEFORE]->(CommaChar)-[:BEFORE]->(In)-[:BEFORE]->(The)-[:BEFORE]->(Which)-[:BEFORE]->(Is)-[:BEFORE]->(The)-[:BEFORE]->(Fruit)-[:BEFORE]->(Of)-[:BEFORE]->(A)-[:BEFORE]->(Tree)-[:BEFORE]->(Yielding)-[:BEFORE]->(Seed)-[:BEFORE]->(SemicolonChar)-[:BEFORE]->(To)-[:BEFORE]->(You)-[:BEFORE]->(It)-[:BEFORE]->(Shall)-[:BEFORE]->(Be)-[:BEFORE]->(For)-[:BEFORE]->(Meat)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(To)-[:BEFORE]->(Every)-[:BEFORE]->(Beast)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(To)-[:BEFORE]->(Every)-[:BEFORE]->(Fowl)-[:BEFORE]->(Of)-[:BEFORE]->(The)-[:BEFORE]->(Air)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(To)-[:BEFORE]->(Every)-[:BEFORE]->(Thing)-[:BEFORE]->(That)-[:BEFORE]->(Creepeth)-[:BEFORE]->(Upon)-[:BEFORE]->(The)-[:BEFORE]->(Earth)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Wherein)-[:BEFORE]->(There)-[:BEFORE]->(Is)-[:BEFORE]->(Life)-[:BEFORE]->(CommaChar)-[:BEFORE]->(I)-[:BEFORE]->(Have)-[:BEFORE]->(Given)-[:BEFORE]->(Every)-[:BEFORE]->(Green)-[:BEFORE]->(Herb)-[:BEFORE]->(For)-[:BEFORE]->(Meat)-[:BEFORE]->(ColonChar)-[:BEFORE]->(And)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(So)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)
CREATE (PhraseStart)-[:BEFORE]->(And)-[:BEFORE]->(God)-[:BEFORE]->(Saw)-[:BEFORE]->(Every)-[:BEFORE]->(Thing)-[:BEFORE]->(That)-[:BEFORE]->(He)-[:BEFORE]->(Had)-[:BEFORE]->(Made)-[:BEFORE]->(CommaChar)-[:BEFORE]->(And)-[:BEFORE]->(CommaChar)-[:BEFORE]->(Behold)-[:BEFORE]->(CommaChar)-[:BEFORE]->(It)-[:BEFORE]->(Was)-[:BEFORE]->(Very)-[:BEFORE]->(Good)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Evening)-[:BEFORE]->(And)-[:BEFORE]->(The)-[:BEFORE]->(Morning)-[:BEFORE]->(Were)-[:BEFORE]->(The)-[:BEFORE]->(Sixth)-[:BEFORE]->(Day)-[:BEFORE]->(PeriodChar)-[:BEFORE]->(PhraseEnd)

兄弟查询:

MATCH
    (a:Token)-[:BEFORE]->(b:Token)-[:BEFORE]-(c:Token),
    (b)-[:BEFORE]->(d:Token)
RETURN c, d

返回所有成对的令牌,两个成对的令牌都紧跟b令牌之后。

当前模型

唯一词节点(将成为同级节点):

CREATE (CommaChar:SibToken {text:','})
CREATE (PeriodChar:SibToken {text:'.'})
CREATE (ColonChar:SibToken {text:':'})
CREATE (SemicolonChar:SibToken {text:';'})
CREATE (A:SibToken {text:'A'})
CREATE (Above:SibToken {text:'ABOVE'})
CREATE (Abundantly:SibToken {text:'ABUNDANTLY'})
CREATE (After:SibToken {text:'AFTER'})
CREATE (Air:SibToken {text:'AIR'})
CREATE (All:SibToken {text:'ALL'})
CREATE (Also:SibToken {text:'ALSO'})
CREATE (And:SibToken {text:'AND'})
CREATE (Appear:SibToken {text:'APPEAR'})
CREATE (Be:SibToken {text:'BE'})
CREATE (Bearing:SibToken {text:'BEARING'})
...
CREATE (Whales:SibToken {text:'WHALES'})
CREATE (Wherein:SibToken {text:'WHEREIN'})
CREATE (Which:SibToken {text:'WHICH'})
CREATE (Whose:SibToken {text:'WHOSE'})
CREATE (Winged:SibToken {text:'WINGED'})
CREATE (Without:SibToken {text:'WITHOUT'})
CREATE (Years:SibToken {text:'YEARS'})
CREATE (Yielding:SibToken {text:'YIELDING'})
CREATE (You:SibToken {text:'YOU'})

连接了单个单词(示例)

CREATE (In0:Token {text: "IN", id: 0})-[:BEFORE]->(The1:Token {text: "THE", id: 1})-[:BEFORE]->(Beginning2:Token {text: "BEGINNING", id: 2})-[:BEFORE]->(God3:Token {text: "GOD", id: 3})-[:BEFORE]->(Created4:Token {text: "CREATED", id: 4})-[:BEFORE]->(The5:Token {text: "THE", id: 5})-[:BEFORE]->(Heaven6:Token {text: "HEAVEN", id: 6})-[:BEFORE]->(And7:Token {text: "AND", id: 7})-[:BEFORE]->(The8:Token {text: "THE", id: 8})-[:BEFORE]->(Earth9:Token {text: "EARTH", id: 9})-[:BEFORE]->(PeriodChar10:Token {text: ".", id: 10})-[:BEFORE]->(And11:Token {text: "AND", id: 11})...(And910:Token {text: "AND", id: 910})-[:BEFORE]->(The911:Token {text: "THE", id: 911})-[:BEFORE]->(Evening912:Token {text: "EVENING", id: 912})-[:BEFORE]->(And913:Token {text: "AND", id: 913})-[:BEFORE]->(The914:Token {text: "THE", id: 914})-[:BEFORE]->(Morning915:Token {text: "MORNING", id: 915})-[:BEFORE]->(Were916:Token {text: "WERE", id: 916})-[:BEFORE]->(The917:Token {text: "THE", id: 917})-[:BEFORE]->(Sixth918:Token {text: "SIXTH", id: 918})-[:BEFORE]->(Day919:Token {text: "DAY", id: 919})-[:BEFORE]->(PeriodChar920:Token {text: ".", id: 920})

兄弟查询:

MATCH (a1:Token)-[:BEFORE]->(b1:Token)-[:BEFORE]->(c1:Token)-[:BEFORE]->(d1:Token)
MATCH (a2:Token)-[:BEFORE]->(b2:Token)-[:BEFORE]->(c2:Token)-[:BEFORE]->(d2:Token)
MATCH (s1:SibToken)
MATCH (s2:SibToken)
WHERE a1.text = a2.text AND b1.text = b2.text AND c1.text = c2.text AND d1.text < d2.text AND s1.text = d1.text AND s2.text = d2.text
CREATE (s1)-[:SIBLING]->(s2)

查询结果图:

Full Sibling Graph

特别有趣的集团:

Verb Cluster

Days and Nouns Clusters