Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

String operator #11

Open
qwang0225 opened this issue Jul 27, 2023 · 1 comment
Open

String operator #11

qwang0225 opened this issue Jul 27, 2023 · 1 comment

Comments

@qwang0225
Copy link

Hi, I'm trying to define a relation that can apply operations like adding a prefix or suffix to a input word, the different operations would also be defined in a relation.

ctx = scallopy.ScallopContext("difftopkproofs")
ctx.add_relation("opr", str, input_mapping=["pref", "suf"])
ctx.add_relation("word1", str)
ctx.add_relation("word2", str)

ctx.add_rule("add_pref(w2+w1)) :- word1(w1), opr("pref"), word2(w2)")
ctx.add_rule("add_suf(w1+w2) :- word1(w1), opr("suf"), word2(w2)")

However, when I run I got an error saying opr takes no argument(expected 1), can you explain where went wrong? Thanks

@Liby99
Copy link
Contributor

Liby99 commented Jul 27, 2023

I think there's syntax error in the code for defining add_pref, I have provided a fix here:

ctx.add_rule("add_pref(w2+w1) :- word1(w1), opr(\"pref\"), word2(w2)")

Notice that for add_pref you have an additional parenthesis and the string "pref" is not escaped.

Can you see whether this fixes the error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants