我认为我对理解比赛结构和比赛变量的范围存在一般性问题。
我遇到问题的具体代码是:
// S sentiment toward A goodFor/badFor T
// => S sentiment toward the idea of A goodFor/badFor T
MATCH (S:A)-[:SOURCE]->(sent1:PS {type:"sentiment"})-[:TARGET]->(gfbf:E {type:"gfbf"}) , (A)-[:SOURCE]->(gfbf)-[:TARGET]->(T) , (Writer:A {type:"writer"})
// if there is some negative belief in any of the writers private state spaces that involve gfbf then inference is blocked
WHERE NOT (Writer)-[*1..]->({type:"believesTrue" , spec:FALSE})-[*1..]->(gfbf)
// if sent1 is in some private state spaces of the writer return all of these
OPTIONAL MATCH p=(Writer)-[*]->(sent1)
WITH NODES(p)[1..-1] AS ps_nodes
WHERE ALL(x IN ps_nodes[1..] WHERE LABELS(x) = "PS")
MERGE (S)-[:SOURCE]->(sent2:PS {type:"sentiment" , spec:(sent1.spec)})-[:TARGET]->(ideaOf:I {name:"ideaOf" , type:"ideaOf"})-[:TARGET]->(gfbf)
ON CREATE SET sent2.name =
CASE sent2.spec
WHEN FALSE THEN "-S"
ELSE "+S"
END
RETURN p
我认为理解这是什么并不重要。它足以看到我假设的结构,但基本上它的作用是:它查找一个子图,其中有路径S-->sent1-->gfbf
和路径A-->gfbf-->T
。如果它发现它创建了一条新路径A-->sent2-->ideaOf-->gfbf
,则根据匹配中节点的属性设置新节点的属性。此外,它会查看是否还有一个路径writer-->...-->sent
,其中...
部分中的所有节点都有标签PS
。如果它找到该路径,那么它将在程序的不同部分返回此进一步的操作。
我得到的错误是:
py2neo.cypher.error.statement.InvalidSyntax: sent1 not defined (line 6, column 58 (offset: 421))
"MERGE (S)-[:SOURCE]->(sent2:PS {type:"sentiment" , spec:(sent1.spec)})-[:TARGET]->(ideaOf:I {name:"ideaOf" , type:"ideaOf"})-[:TARGET]->(g"bf)
为什么sent1
不再定义我使用它的位置以及如何重新构建代码以使其有效?
答案 0 :(得分:0)
sent1 in不在之前的WITH中 - 改变它:
WITH NODES(p)[1..-1] AS ps_nodes, sent1