I saw a voice somewhere on the net saying "pyswip is convenient, but it doesn't support python 3 ~ crying".
I wrote this article with the intention of reporting that "** python3.8.2 worked fine with pyswip **".
It's a slapstick, but unless you're a prophet, you can't say that it works with python3. Even if it works with python3.8.2, there is no logical guarantee that it will work with python3.8.3 or later. </ sub> </ sub>
1. pip install pyswip
2. Execute the following code
from pyswip import Prolog
p = Prolog()
p.assertz("father(michael, john)")
p.assertz("father(michael, gina)")
for s in p.query("father(X,Y)"):
print(s["X"], "is the father of", s["Y"])
micheal is the father of john
micheal is the father of gina
Reference: "Examples" at https://github.com/yuce/pyswip
Recommended Posts