剪辑python绑定
clipsp的Python项目详细描述
pythonCFFI用于“c”语言集成生产系统的绑定CLIPS6.30。
Source: | https://github.com/noxdafox/clipspy |
---|---|
Documentation: | https://clipspy.readthedocs.io |
Download: | https://pypi.python.org/pypi/clipspy |
CLIPS最初是在美国宇航局约翰逊航天中心开发的,是一种基于规则的编程语言,用于创建专家和生产系统,其中启发式解决方案比命令式解决方案更易于实现和维护clips旨在促进软件的开发,以模拟人类的知识或专长。
clipspy在python生态系统中带来了clips功能。
安装
窗口
CLIPSPy对于大多数Python版本和架构来说都是一个轮子因此,它可以从Pip安装
> pip install clipspy
Linux
借记和衍生
clip6.30在unstable中作为debian包提供。
# apt install libclips libclips-dev
# pip install clipspy
从源头建造
提供的makefile负责检索clips源代码并与之一起编译python绑定。
$ make
# make install
构建源代码需要以下工具。
- gcc
- make
- wget
- unzip
- python
- python-cffi
Makefile接受以下条件变量
- PYTHON: Python interpreter to use, default python
- CLIPS_SOURCE_URL: Location from where to retrieve CLIPS source code archive.
- SHARED_LIBRARY_DIR: Path where to install CLIPS shared library, default /usr/lib
示例
fromclipsimportEnvironment,Symbolenvironment=Environment()# load constructs into the environmentenvironment.load('constructs.clp')# assert a fact as stringenvironment.assert_string('(a-fact)')# retrieve a fact templatetemplate=environment.find_template('a-fact')# create a new fact from the templatefact=template.new_fact()# implied (ordered) facts are accessed as listsfact.append(42)fact.extend(("foo","bar"))# assert the fact within the environmentfact.assertit()# retrieve another fact templatetemplate=environment.find_template('another-fact')fact=template.new_fact()# template (unordered) facts are accessed as dictionariesfact["slot-name"]=Symbol("foo")fact.assertit()# execute the activations in the agendaenvironment.run()