pyswip允许在python程序中查询swi prolog。
pyswip的Python项目详细描述
PYSWIP
有什么新消息?
请参阅CHANGELOG。
正在清理和重构此库。预计API会损坏,并且与以前的版本不兼容。
感谢所有的contributors。如果您以前为pyswip做过贡献,而您的名字没有出现在列表中,请let me know这样我可以添加您的名字。
简介
pyswip是一个python-swi prolog桥,允许在python程序中查询SWI-Prolog。 它具有一个(不完整的)swi-prolog外语接口,一个使prolog查询变得容易的实用程序类,以及一个 pythonic接口。
由于pyswip使用swi prolog作为共享库,使用cTypes访问它,因此不需要安装编译。
要求:
- Python2.7或3.4及更高版本。
- 当前不支持pypy。
- swi prolog 7.2.x及更高版本。
libswipl
作为共享库。这是大多数平台上的默认值。- 适用于Linux、Windows、MacOS和FreeBSD。应该在其他POSIX上工作。
安装
有关说明,请参见INSTALL。
示例
使用prolog
frompyswipimportPrologprolog=Prolog()prolog.assertz("father(michael,john)")prolog.assertz("father(michael,gina)")list(prolog.query("father(michael,X)"))==[{'X':'john'},{'X':'gina'}]forsolninprolog.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
存储在Prolog文件中的现有知识库也可以咨询, 并质疑道。假设文件名为“knowledge_base.pl”,并且python是 在同一个工作目录中运行时,可以这样咨询:
>>> from pyswip import Prolog
>>> prolog = Prolog()
>>> prolog.consult("knowledge_base.pl")
外部功能
from__future__importprint_functionfrompyswipimportProlog,registerForeigndefhello(t):print("Hello,",t)hello.arity=1registerForeign(hello)prolog=Prolog()prolog.assertz("father(michael,john)")prolog.assertz("father(michael,gina)")print(list(prolog.query("father(michael,X), hello(X)")))
Python接口(实验性)
from__future__importprint_functionfrompyswipimportFunctor,Variable,Query,callassertz=Functor("assertz",1)father=Functor("father",2)call(assertz(father("michael","john")))call(assertz(father("michael","gina")))X=Variable()q=Query(father("michael",X))whileq.nextSolution():print("Hello,",X.value)q.closeQuery()# Outputs:# Hello, john# Hello, gina
Prolog.query
的核心功能基于nathan denny的公共域prolog.py。
救命啊!
联系人
yucetekol@gmail.com
- https://twitter.com/tklx
使用或引用pyswip的项目/出版物
您有使用/提到pyswip的项目、视频或出版物吗?Please let me know或发送拉取请求。
书籍
出版物
- Assessment of Graph Databases as a Viable Materiel Solution for the Army's Dynamic Force Structure (DFS) Portal Implementation: Part 3, Risks, Mitigation Approach, and Roadmap
- Tackling Complexity in High Performance Computing Applications
- Social Human-Robot Interaction: A New Cognitive and Affective Interaction-Oriented Architecture
- A Planning Module for a ROS-Based Ubiquitous Robot Control System(pdf)
- A pilot framework developed as a common platform integrating diverse elements of computer aided fixture design
- Integration von Prolog und ClioPatria in Python(pdf,德语)
- SELECTSCRIPT: A Query Language for Robotic World Models and Simulations
- A Concept for Declarative Information Acquisition in Smart Environments
- Implementation on ADHD Diagnostic Expert System based on DSM Diagnostic Criteria(pdf,朝鲜语)
- Wie sehen Krebsmolekule aus? Vergleich der Gute der Klassifizierung potenziell krebserregender Molekule durch induktiv logische und merkmalsbasierte Lernverfahren(pdf,德语)
- Companion Robots Behaving with Style: Towards Plasticity in Social Human-Robot Interaction(pdf)
视频
- AI - blocks world solver interactive planner
- PySwip, Prolog, JAVA SCRIPT and HTML(西班牙语)
- GET OUT OF THE MAZE WITH PROLOG AND PYTHON(西班牙语)
项目
- noworkflow支持在没有科学工作流管理系统的情况下运行科学实验的基础设施。http://gems-uff.github.io/noworkflow
- Super Pacman
- Pokemon Weak Detector
- Food Recommendations in Hyderabad, India食物推荐人工智能专家系统,使用位于烧瓶上的图形用户界面和使用pyswip和本地prolog开发的后端
- pyswip_envctrl用pyswip编写的环境控制模块专家系统。
- tic-tac-toe在prolog中使用ai,在python中使用gui的tic tac-toe游戏(kivy framework+pyswip)
- TBM1 - "Getting to Know My Home"
- A script that enables use of a Prolog natural language parsing component to control a Scribbler II robot over bluetooth
- Cosmos一种新的逻辑程序设计语言。
- lib-annotated-attack-trees用于创建带注释的攻击树库并使用它优化带注释的攻击树的脚本和资源。
- ClIDE命令行智能开发环境
- Artificial Intelligence INF1771 @ PUC-Rio人工智能类项目@puc rio
- AutomobileAdvisor项目名称系统Ekspertowe pomagaj_cy wybraćodpowiedni samochód dla danego klienta na podstawie preferencji(波兰语)
- Prolog Tetris AI
博客文章
- Calling Prolog from Python
- Python v. Prolog: Round 1: Fight!
- Path Follower: Arduino+Rasp on ROS及其Project code。
许可证
Copyright (c) 2007-2018 Yüce Tekol
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.