Name | pyswip JSON |
Version |
0.3.2
JSON |
| download |
home_page | None |
Summary | PySwip enables querying SWI-Prolog in your Python programs. |
upload_time | 2024-10-27 18:26:39 |
maintainer | None |
docs_url | None |
author | None |
requires_python | >=3.9 |
license | None |
keywords |
ai
artificial intelligence
ctypes
ffi
prolog
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
<a href="https://pypi.python.org/pypi/pyswip"><img src="https://img.shields.io/pypi/v/pyswip.svg?maxAge=2592&updated=2"></a>
<img src="https://img.shields.io/github/actions/workflow/status/yuce/pyswip/tests.yaml">
<a href="https://coveralls.io/github/yuce/pyswip"><img src="https://coveralls.io/repos/github/yuce/pyswip/badge.svg?branch=master"></a>
<a href="https://pyswip.readthedocs.io/en/latest/"><img src="https://readthedocs.org/projects/pyswip/badge/?version=latest"></a>
# PySwip
<div align="center">
<img src="https://pyswip.org/images/pyswip_logo_sm_256colors.gif" alt="PySwip logo">
</div>
## What's New?
See the [Change Log](https://pyswip.org/change-log.html).
## Install
If you have SWI-Prolog installed, it's just:
```
pip install -U pyswip
```
See [Get Started](https://pyswip.readthedocs.io/en/latest/get_started.html) for detailed instructions.
## Introduction
PySwip is a Python-Prolog interface that enables querying [SWI-Prolog](https://www.swi-prolog.org) in your Python programs.
It features an SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.
Since PySwip uses SWI-Prolog as a shared library and ctypes to access it, it doesn't require compilation to be installed.
PySwip was brought to you by the PySwip community.
Thanks to all [contributors](CONTRIBUTORS.txt).
## Documentation
* [PySwip Home](https://pyswip.org)
* [PySwip Documentation](https://pyswip.readthedocs.io/en/latest/)
## Examples
### Using Prolog
```python
from pyswip import Prolog
Prolog.assertz("father(michael,john)")
Prolog.assertz("father(michael,gina)")
list(Prolog.query("father(michael,X)")) == [{'X': 'john'}, {'X': 'gina'}]
for soln in Prolog.query("father(X,Y)"):
print(soln["X"], "is the father of", soln["Y"])
# michael is the father of john
# michael is the father of gina
```
An existing knowledge base stored in a Prolog file can also be consulted, and queried.
Assuming the filename "knowledge_base.pl" and the Python is being run in the same working directory, it is consulted like so:
```python
from pyswip import Prolog
Prolog.consult("knowledge_base.pl")
```
### Foreign Functions
```python
from pyswip import Prolog, registerForeign
def hello(t):
print("Hello,", t)
hello.arity = 1
registerForeign(hello)
Prolog.assertz("father(michael,john)")
Prolog.assertz("father(michael,gina)")
print(list(Prolog.query("father(michael,X), hello(X)")))
```
### Pythonic interface (Experimental)
```python
from pyswip import Functor, Variable, Query, call
assertz = Functor("assertz", 1)
father = Functor("father", 2)
call(assertz(father("michael","john")))
call(assertz(father("michael","gina")))
X = Variable()
q = Query(father("michael",X))
while q.nextSolution():
print("Hello,", X.value)
q.closeQuery()
# Outputs:
# Hello, john
# Hello, gina
```
The core functionality of `Prolog.query` is based on Nathan Denny's public domain prolog.py.
## Help!
* [Support Forum](https://groups.google.com/forum/#!forum/pyswip)
* [Stack Overflow](https://stackoverflow.com/search?q=pyswip)
## PySwip Community Home
PySwip was used in scientific articles, dissertations, and student projects over the years.
Head out to [PySwip Community](https://pyswip.org/community.html) for more information and community links.
**Do you have a project, video or publication that uses/mentions PySwip?**
**[file an issue](https://github.com/yuce/pyswip/issues/new?title=Powered%20by%20PySwip) or send a pull request.**
If you would like to reference PySwip in a LaTeX document, you can use the provided [BibTeX file](https://pyswip.org/pyswip.bibtex).
You can also use the following information to refer to PySwip:
* Author: YĆ¼ce Tekol and PySwip contributors
* Title: PySwip VERSION
* URL: https://pyswip.org
## License
PySwip is licensed under the [MIT license](LICENSE).
Raw data
{
"_id": null,
"home_page": null,
"name": "pyswip",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "ai, artificial intelligence, ctypes, ffi, prolog",
"author": null,
"author_email": "Yuce Tekol <yucetekol@gmail.com>",
"download_url": "https://files.pythonhosted.org/packages/b3/15/487cfdecb514a14ac8382f7994841346d5c2fa18d3ddbe1108dc5109baa1/pyswip-0.3.2.tar.gz",
"platform": null,
"description": "<a href=\"https://pypi.python.org/pypi/pyswip\"><img src=\"https://img.shields.io/pypi/v/pyswip.svg?maxAge=2592&updated=2\"></a>\n<img src=\"https://img.shields.io/github/actions/workflow/status/yuce/pyswip/tests.yaml\">\n<a href=\"https://coveralls.io/github/yuce/pyswip\"><img src=\"https://coveralls.io/repos/github/yuce/pyswip/badge.svg?branch=master\"></a>\n<a href=\"https://pyswip.readthedocs.io/en/latest/\"><img src=\"https://readthedocs.org/projects/pyswip/badge/?version=latest\"></a>\n\n\n# PySwip\n\n<div align=\"center\">\n <img src=\"https://pyswip.org/images/pyswip_logo_sm_256colors.gif\" alt=\"PySwip logo\">\n</div>\n\n## What's New?\n\nSee the [Change Log](https://pyswip.org/change-log.html).\n\n## Install\n\nIf you have SWI-Prolog installed, it's just:\n```\npip install -U pyswip\n```\n\nSee [Get Started](https://pyswip.readthedocs.io/en/latest/get_started.html) for detailed instructions.\n\n## Introduction\n\nPySwip is a Python-Prolog interface that enables querying [SWI-Prolog](https://www.swi-prolog.org) in your Python programs.\nIt features an SWI-Prolog foreign language interface, a utility class that makes it easy querying with Prolog and also a Pythonic interface.\n\nSince PySwip uses SWI-Prolog as a shared library and ctypes to access it, it doesn't require compilation to be installed.\n\nPySwip was brought to you by the PySwip community.\nThanks to all [contributors](CONTRIBUTORS.txt).\n\n## Documentation\n\n* [PySwip Home](https://pyswip.org)\n* [PySwip Documentation](https://pyswip.readthedocs.io/en/latest/)\n\n## Examples\n\n### Using Prolog\n\n```python\nfrom pyswip import Prolog\nProlog.assertz(\"father(michael,john)\")\nProlog.assertz(\"father(michael,gina)\")\nlist(Prolog.query(\"father(michael,X)\")) == [{'X': 'john'}, {'X': 'gina'}]\nfor soln in Prolog.query(\"father(X,Y)\"):\n print(soln[\"X\"], \"is the father of\", soln[\"Y\"])\n# michael is the father of john\n# michael is the father of gina\n```\n\nAn existing knowledge base stored in a Prolog file can also be consulted, and queried.\nAssuming the filename \"knowledge_base.pl\" and the Python is being run in the same working directory, it is consulted like so:\n\n```python\nfrom pyswip import Prolog\nProlog.consult(\"knowledge_base.pl\")\n```\n\n### Foreign Functions\n\n```python\nfrom pyswip import Prolog, registerForeign\n\ndef hello(t):\n print(\"Hello,\", t)\nhello.arity = 1\n\nregisterForeign(hello)\n\nProlog.assertz(\"father(michael,john)\")\nProlog.assertz(\"father(michael,gina)\")\nprint(list(Prolog.query(\"father(michael,X), hello(X)\")))\n```\n\n### Pythonic interface (Experimental)\n\n```python\nfrom pyswip import Functor, Variable, Query, call\n\nassertz = Functor(\"assertz\", 1)\nfather = Functor(\"father\", 2)\ncall(assertz(father(\"michael\",\"john\")))\ncall(assertz(father(\"michael\",\"gina\")))\nX = Variable()\n\nq = Query(father(\"michael\",X))\nwhile q.nextSolution():\n print(\"Hello,\", X.value)\nq.closeQuery()\n\n# Outputs:\n# Hello, john\n# Hello, gina\n```\n\nThe core functionality of `Prolog.query` is based on Nathan Denny's public domain prolog.py.\n\n## Help!\n\n* [Support Forum](https://groups.google.com/forum/#!forum/pyswip)\n* [Stack Overflow](https://stackoverflow.com/search?q=pyswip)\n\n## PySwip Community Home\n\nPySwip was used in scientific articles, dissertations, and student projects over the years.\nHead out to [PySwip Community](https://pyswip.org/community.html) for more information and community links.\n\n**Do you have a project, video or publication that uses/mentions PySwip?**\n**[file an issue](https://github.com/yuce/pyswip/issues/new?title=Powered%20by%20PySwip) or send a pull request.**\n\nIf you would like to reference PySwip in a LaTeX document, you can use the provided [BibTeX file](https://pyswip.org/pyswip.bibtex).\nYou can also use the following information to refer to PySwip:\n* Author: Y\u00fcce Tekol and PySwip contributors\n* Title: PySwip VERSION\n* URL: https://pyswip.org\n\n## License\n\nPySwip is licensed under the [MIT license](LICENSE).\n",
"bugtrack_url": null,
"license": null,
"summary": "PySwip enables querying SWI-Prolog in your Python programs.",
"version": "0.3.2",
"project_urls": {
"Download": "https://github.com/yuce/pyswip/releases",
"Homepage": "https://pyswip.org"
},
"split_keywords": [
"ai",
" artificial intelligence",
" ctypes",
" ffi",
" prolog"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "8695cc9bf8920642e10919cb268dc19076bb5fb6290435d0ea254bd5defe68bc",
"md5": "9866a17a01a21121a4e35742a1972f38",
"sha256": "88cc837be54ad293f547e4fb3fab7bb997138eaa7c2175781c45fd266ea6a98d"
},
"downloads": -1,
"filename": "pyswip-0.3.2-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9866a17a01a21121a4e35742a1972f38",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.9",
"size": 35478,
"upload_time": "2024-10-27T18:26:37",
"upload_time_iso_8601": "2024-10-27T18:26:37.604866Z",
"url": "https://files.pythonhosted.org/packages/86/95/cc9bf8920642e10919cb268dc19076bb5fb6290435d0ea254bd5defe68bc/pyswip-0.3.2-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b315487cfdecb514a14ac8382f7994841346d5c2fa18d3ddbe1108dc5109baa1",
"md5": "c1abc16c561bedb293bbec0cc78c9e0d",
"sha256": "7708c97bb0649b1f4465bebb833e2928389e8760a81dcde2578c87a5b7620fef"
},
"downloads": -1,
"filename": "pyswip-0.3.2.tar.gz",
"has_sig": false,
"md5_digest": "c1abc16c561bedb293bbec0cc78c9e0d",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 35282,
"upload_time": "2024-10-27T18:26:39",
"upload_time_iso_8601": "2024-10-27T18:26:39.501403Z",
"url": "https://files.pythonhosted.org/packages/b3/15/487cfdecb514a14ac8382f7994841346d5c2fa18d3ddbe1108dc5109baa1/pyswip-0.3.2.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-10-27 18:26:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "yuce",
"github_project": "pyswip",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "pyswip"
}