Skip to main content

DyLan, the Dynamic Syntax parser in Python

Project description

dynamicsyntax

dynamicsyntax is the python implementation of the DyLan the Dynamic Syntax parser. It has been (vibe) translated from Java to Python by @incrementaliser using Cursor, and is still under development.

Installation

You need uv and a Python that satisfies >=3.11 (see pyproject.toml).

  1. Create a virtual environment with a fixed Python version (run this in the directory where you want .venv, e.g. the repo root for a clone):

    uv venv --python 3.12
    
  2. Activate it. On Linux or macOS:

    source .venv/bin/activate
    

    On Windows, use .venv\Scripts\activate (cmd) or .\.venv\Scripts\Activate.ps1 (PowerShell).

  3. Install into that environment, using the published package from PyPI:

    uv pip install dynamicsyntax
    

    or editable install from a git clone:

    uv pip install -e .
    

Examples

dynamicsyntax.parse returns a ParseResult (with .semantics, .ok, .tree, .vis(), and .address_order). This replaces older versions that returned TTRRecordType | None directly—use .semantics for the final TTR record.

List bundled grammars and (placeholder) datasets:

import dynamicsyntax as ds

print(ds.get_grammars())   # e.g. ['2015-english-ttr', 'ttr', ...]
print(ds.get_datasets()) # [] until datasets ship with the package

One-shot parse with a grammar id or alias ("ttr" maps to 2015-english-ttr):

import dynamicsyntax as ds

p = ds.parse("a man arrives", "ttr")
print(p.ok, p.semantics)
p.vis()  # prints the same address-order tree view as the GUI

Load a grammar once, then parse without repeating the grammar argument:

import dynamicsyntax as ds

ds.load_grammar("ttr")  # or ds.load_grammar("2015-english-ttr")
p = ds.parse("a man arrives")
print(p.semantics)
p.vis()

Use a filesystem path to a grammar directory (as in the GUI “load folder” flow):

import dynamicsyntax as ds
from pathlib import Path

ds.load_grammar(Path("/path/to/grammar-dir"))
p = ds.parse("go to the red box")

Testing

See testing.md for how to run pytest with uv, show per-test pass/fail output, and useful options (-v, --lf, subsets, and CI).

Get Involved

Contributions (issues, PRs, donations) are very welcome! Since this project has been translated using Cursor and tested only on Windows, there is a small chance errors exist. I would be grateful if you could report them to me through the above channels. Although, it is important to mention that some of the most critical methods here have been verified via unit tests, so there is a high chance the migration from Java has been corrrect so far.

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

dynamicsyntax-0.2.1.tar.gz (159.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dynamicsyntax-0.2.1-py3-none-any.whl (210.9 kB view details)

Uploaded Python 3

File details

Details for the file dynamicsyntax-0.2.1.tar.gz.

File metadata

  • Download URL: dynamicsyntax-0.2.1.tar.gz
  • Upload date:
  • Size: 159.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dynamicsyntax-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0a77592a68e2b5264e4d850659403c9d9ef210e7c8aeee251465c7b7b0357ede
MD5 9fba1859ccd4818e1eb61ed0612784ba
BLAKE2b-256 629ec00ff313a4d55f459346b58a643a1fa3b62abb88de1a7fa57324358f2304

See more details on using hashes here.

File details

Details for the file dynamicsyntax-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: dynamicsyntax-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 210.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for dynamicsyntax-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 9dc325ff48d239900d2ceea8e8f05dee6c6a0dcfb16f2cf2f37da7a085512b1a
MD5 f509ed3f907ee1981de5638b7b9f333c
BLAKE2b-256 ce78881b668fde19608b5a6de832f4c382bf594f9a4d9bd6610ef131abd52107

See more details on using hashes here.

Supported by

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