ASPars
Quick and easy parsing of Answer Sets into friendly python structures.
Specification
ASPars allows the user to parse answer sets represented in the following formats:
- wasp format, e.g.,
{a, b(x), c(y,...,z), ...}, - clasp format, e.g.,
a b(x) c(y,...,z) ....
An answer set is parsed into a list of predicates. A predicate is represented as a dictionary with the following keys:
name: name of the predicate,ext: a list of the (heterogeneous) values of the predicate,arity: arity of the predicate (e.g., length of the extension).
If the predicate is an atom, then only name is defined.
Example
{a, foo(x), bar(42,"42")} is parsed into the following singleton:
[
{'name': 'a'},
{'name': 'foo', 'ext': ['x'], 'arity': 1},
{'name': 'bar', 'ext': [42, '"42"'], 'arity': 2}
]
Usage
ASPars can be used by simply importing it or as a standalone module.
Importing ASPars in a python program
from aspars import ASPars
answer_sets_waspf = [
'{a, foo(x), bar(-1,1), fizz("42")}',
'{b, foo(y), bar(-2,2)}',
'{c, foo(z), fizz("24")}',
]
# parses only the first answer set, returns a singleton
single = ASPars(syntax='wasp').parse(answer_sets_waspf[0])
# parse all the answer sets, returns an iterable (map)
multi = ASPars(syntax='wasp').parse(answer_sets_waspf)
# example in clasp syntax
single = ASPars(syntax='clasp').parse('b foo(y) bar(-2,2)')
Using ASPars as a standalone module
$ cat my_answer_sets | python -m aspars
Metadata
Release files for aspars 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| aspars-0.1.0.tar.gz | 2.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| aspars-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.9 kB
Release files / aspars-0.1.0.tar.gz
| Download URL | aspars-0.1.0.tar.gz |
|---|---|
| Size | 2.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
2d4d1dd716c8627b34a402d07d66615c9c1843ce46d036f348830727bdfb4414
|
|
BLAKE2b-256 checksum How to use checksums |
a2f1fd2006bb582f999318243e7869e267e9eb3aa08c140b321eb699a1cf3581
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|
Release files / aspars-0.1.0-py3-none-any.whl
| Download URL | aspars-0.1.0-py3-none-any.whl |
|---|---|
| Size | 4.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
74dbc97a41804c2c7219e2bc2a23127829b47cecaf0d9df217547009620ecfd4
|
|
BLAKE2b-256 checksum How to use checksums |
729bc83554a5e5378994853afd88ea42ce7cb3c9de0920977586f539f3db8c46
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
|
Security for aspars 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.