Metadata-Version: 2.1
Name: pydavid
Version: 1.0.0
Summary: A simple Python interface of Open-David
Home-page: https://github.com/toda-lab/pydavid
License: MIT
Keywords: logic,inference,abduction,explanation,artificial intelligence
Author: Takahisa Toda
Author-email: toda@disc.lab.uec.ac.jp
Requires-Python: >=3.8,<4.0
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Science/Research
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Provides-Extra: docs
Provides-Extra: test
Requires-Dist: Sphinx (>=7.1.2,<8.0.0) ; extra == "docs"
Requires-Dist: dhgraph (>=1.0.0,<2.0.0)
Requires-Dist: pallets-sphinx-themes (>=2.1.1,<3.0.0) ; extra == "docs"
Requires-Dist: pytest (>=8.1.1,<9.0.0) ; extra == "test"
Requires-Dist: sphinx-removed-in (>=0.2.1,<0.3.0) ; extra == "docs"
Requires-Dist: sphinxcontrib-trio (>=1.1.2,<2.0.0) ; extra == "docs"
Project-URL: Repository, https://github.com/toda-lab/pydavid
Description-Content-Type: text/x-rst

pydavid: A simple Python Interface of Open-David
==========================================================

Introduction
============
``pydavid`` is a simple Python interface of Open-David, an abductive reasoner written in C++.

Installation
============
``pydavid`` is a frontend of Open-David and does not include Open-David.
Please install `Open-David <https://github.com/aurtg/open-david>`__ ,
and then install ``pydavid`` by the following command.

.. code:: shell-session

    $ pip install pydavid

Usage
=====

The following is a sample code.
Before run, please set approapriate path to an executable file of Open-David
in your computer, download ``toy.dav`` in this repository, and
place it in your current working directly.

.. code:: python

    from pydavid    import OpenDavid
    from dhgraph    import DirectedHypergraph

    # PLEASE MODIFY PATH ACCORDING TO YOUR ENVIRONMENT.
    OpenDavid.set_david_path("/usr/local/bin/david")
    with open("toy.dav", mode="r") as f:
        data = f.read()
        OpenDavid.set_knowledge_base(data)

    observation_list = ["police(John)", "die(E1)", "subj(E1, Mary)",\
        "arrest(E2)", "subj(E2, x)", "obj(E2, Bob)"]
    required_atom_list = ["(x = John)"]
    OpenDavid.set_problem(observation_list, required_atom_list)
    json_str = OpenDavid.run() # Wait until it terminates if interpreter is used.

    # json is converted to a directed hypergraph.
    g = OpenDavid.build_proofgraph(json_str) 
    # "sample.png" will be generated in your cwd.
    g.render(filename="sample", format="png")

NOTE: ``toy.dav`` distributed in this repository was obtained from 
`Open-David <https://github.com/aurtg/open-david>`__ , but a problem field was
deleted, because ``pydavid`` separately sets knowledge base data and a problem data.

Please see `dhgraph <https://github.com/toda-lab/dhgraph>`__ for usage of
dhgraph.


.. image:: sample.png
    :alt: sample.png

Bugs/Requests/Discussions
=========================

Please report bugs and requests from `GitHub Issues <https://github.com/toda-lab/pydavid/issues>`__ , and 
ask questions from `GitHub Discussions <https://github.com/toda-lab/pydavid/discussions>`__ .

License
=======

Please see `LICENSE <https://github.com/toda-lab/pydavid/blob/main/LICENSE>`__ .

