Souffle查询返回零结果

huangapple go评论44阅读模式
英文:

Souffle query returning zero results

问题

我正在编写一个在家庭关系上操作的[Souffle](https://souffle-lang.github.io/)查询:

.decl Parent(x: symbol, y: symbol)
.input Parent

.decl Descendant(x: symbol, y: symbol)
.output Descendant
.printsize Descendant

Descendant(x, y) :- Parent(x, y).
Descendant(x, y) :- Parent(z, y), Descendant(x, z).

.decl Qslow(x: symbol)
.output Qslow
.printsize Qslow

Qslow(x) :- Descendant("Alice", x).


我有一些事实在一个TSV文件`Parent.facts`中:

"Alice" "john"
"john" "mary"
"mary" "elizabeth"
"Bob" "charles"


运行`souffle`似乎为`Descendant`关系生成了正确的输出(对于"Alice"有三个后代):

hickory% souffle -F. -D. descendants.dl
Descendant 7
Qslow 0
hickory%


然而,`Qslow`产生了**零**结果。我本来希望有**三**个结果。这让我怀疑`Qslow`的定义,但我不确定问题是什么。我是否在符号语法上做了一些奇怪的事情?看起来我使用的语法与[文档中的](https://souffle-lang.github.io/types#float-type)相同。

如果我尝试在连接中添加另一个子句,仍然会得到零结果:

Qslow(x) :- Descendant(y, x), y="Alice".


<details>
<summary>英文:</summary>

I am writing a [Souffle](https://souffle-lang.github.io/) query that operates on family relationships:

.decl Parent(x: symbol, y: symbol)
.input Parent

.decl Descendant(x: symbol, y: symbol)
.output Descendant
.printsize Descendant

Descendant(x, y) :- Parent(x, y).
Descendant(x, y) :- Parent(z, y), Descendant(x, z).

.decl Qslow(x: symbol)
.output Qslow
.printsize Qslow

Qslow(x) :- Descendant("Alice", x).


I have some facts in a TSV file `Parent.facts`:

"Alice" "john"
"john" "mary"
"mary" "elizabeth"
"Bob" "charles"


And running `souffle` seems to generate the right output for the `Descendant` relation (three descendants for &quot;Alice&quot;):

hickory% souffle -F. -D. descendants.dl
Descendant 7
Qslow 0
hickory%


However, `Qslow` produces **zero** results. I would instead expect **three** results. This makes me suspicious of the definition of `Qslow`, but I am not sure what the issue is. Am I doing something weird with symbol syntax? It looks like I am using the same syntax as [in the docs](https://souffle-lang.github.io/types#float-type).

If I try adding another clause to the conjunction, I still get zero results:

Qslow(x) :- Descendant(y, x), y="Alice".


</details>


# 答案1
**得分**: 2

您已经在错误的数据格式中指定了文件 `Parent.facts`。它应该是

```Alice	john
john	mary
mary	elizabeth
Bob	charles

不带双引号,并且使用制表符来分隔元组的元素。程序中只有事实使用双引号。

英文:

You have specified the file Parent.facts in the wrong data format. It should be

john	mary
mary	elizabeth
Bob	charles

without double quotes and tabs to separate elements of tuples. Only facts in the program use double-quotes.

huangapple
  • 本文由 发表于 2023年2月18日 04:32:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/75489022.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定