Skip to main content

Python port of DyLan Dynamic Syntax + TTR (parser core)

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.13 (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.13
    
  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.0.tar.gz (158.8 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.0-py3-none-any.whl (210.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dynamicsyntax-0.2.0.tar.gz
  • Upload date:
  • Size: 158.8 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.0.tar.gz
Algorithm Hash digest
SHA256 dae4b01f98ab00b9366845a5624bda7190066162871cf49638566b3a58af4d1e
MD5 0f78806de3345e5a36e131649b2ec955
BLAKE2b-256 462be5a5cd2120ac4088641bd62820c83b4f8f37ec647226fcb8c2218645c50c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dynamicsyntax-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 210.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa92ba73fe471bef768b19c8cc1da087abd618b13006c1666bfd8f390f126c4e
MD5 62dc42f1274aadeb81ef36f0c7d51105
BLAKE2b-256 133dcc517fa73f02bd29c006a6cd46daf33c5a2824492809b2ede35d64f02817

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