{"id":16389578,"url":"https://github.com/yuce/pyswip","last_synced_at":"2025-05-14T13:06:02.281Z","repository":{"id":11727936,"uuid":"14251284","full_name":"yuce/pyswip","owner":"yuce","description":"PySwip is a Python-Prolog interface that enables querying SWI-Prolog in your Python programs.","archived":false,"fork":false,"pushed_at":"2024-12-12T19:23:02.000Z","size":427,"stargazers_count":506,"open_issues_count":23,"forks_count":98,"subscribers_count":32,"default_branch":"master","last_synced_at":"2025-04-11T06:02:07.435Z","etag":null,"topics":["artificial-intelligence","expert-systems","logic-programming","natural-language-processing","prolog","python","robotics","swi-prolog"],"latest_commit_sha":null,"homepage":"https://pyswip.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yuce.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-11-09T04:39:36.000Z","updated_at":"2025-03-27T20:24:24.000Z","dependencies_parsed_at":"2023-02-10T16:31:03.253Z","dependency_job_id":"2517513c-4601-460c-a9f1-1146faaf62d8","html_url":"https://github.com/yuce/pyswip","commit_stats":{"total_commits":246,"total_committers":42,"mean_commits":5.857142857142857,"dds":0.6138211382113821,"last_synced_commit":"0e9a952c140840e451d6f3bf05d4d6ca0311f59b"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Fpyswip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Fpyswip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Fpyswip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yuce%2Fpyswip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yuce","download_url":"https://codeload.github.com/yuce/pyswip/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254149948,"owners_count":22022851,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["artificial-intelligence","expert-systems","logic-programming","natural-language-processing","prolog","python","robotics","swi-prolog"],"created_at":"2024-10-11T04:33:41.399Z","updated_at":"2025-05-14T13:06:02.257Z","avatar_url":"https://github.com/yuce.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003ca href=\"https://pypi.python.org/pypi/pyswip\"\u003e\u003cimg src=\"https://img.shields.io/pypi/v/pyswip.svg?maxAge=2592\u0026updated=2\"\u003e\u003c/a\u003e\n\u003cimg src=\"https://img.shields.io/github/actions/workflow/status/yuce/pyswip/tests.yaml\"\u003e\n\u003ca href=\"https://coveralls.io/github/yuce/pyswip\"\u003e\u003cimg src=\"https://coveralls.io/repos/github/yuce/pyswip/badge.svg?branch=master\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pyswip.readthedocs.io/en/latest/\"\u003e\u003cimg src=\"https://readthedocs.org/projects/pyswip/badge/?version=latest\"\u003e\u003c/a\u003e\n\n\n# PySwip\n\n\u003cdiv align=\"center\"\u003e\n    \u003cimg src=\"https://pyswip.org/images/pyswip_logo_sm_256colors.gif\" alt=\"PySwip logo\"\u003e\n\u003c/div\u003e\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üce 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","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuce%2Fpyswip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyuce%2Fpyswip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyuce%2Fpyswip/lists"}