Skip to main content

A simple Python interface of Open-David

Project description

pydavid: A simple Python Interface of Open-David

Introduction

pydavid is a simple Python interface of Open-David (version 1.73), an abductive reasoner written in C++.

Installation

pydavid is a frontend of Open-David and does not include Open-David. Please install Open-David , and then install pydavid by the following command.

$ 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.

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 , but a problem field was deleted, because pydavid separately sets knowledge base data and a problem data.

Please see dhgraph for usage of dhgraph.

sample.png

Bugs/Requests/Discussions

Please report bugs and requests from GitHub Issues , and ask questions from GitHub Discussions .

License

Please see LICENSE .

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pydavid-1.0.1.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

pydavid-1.0.1-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file pydavid-1.0.1.tar.gz.

File metadata

  • Download URL: pydavid-1.0.1.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for pydavid-1.0.1.tar.gz
Algorithm Hash digest
SHA256 bc0b8477cbb6896e7981bba55acc6846630199cb7758fbfa0385949f47c60741
MD5 8ca04875b3f81512e2825301abb5540d
BLAKE2b-256 fa6b98c46ff7603b018ab6e947f3320dc3b90e14f549fa76fa8f05b9e9535bab

See more details on using hashes here.

File details

Details for the file pydavid-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: pydavid-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

File hashes

Hashes for pydavid-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3ba9e116bfb63be1b8f5226716e81715822426b791dcd0a145da2e56ffa7be10
MD5 6e45f742b05233d236b6b3d7f01e474f
BLAKE2b-256 08f2a02432758c766dfd15e2e435a205bcc639c3f7545f92d22a710b7fb885cc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page