Skip to content

Commit e9e7fdd

Browse files
feat(docs): enhance session info in Pyodide API and GUI for better user experience.
- Introduced CONTEXT.md to provide a comprehensive overview of the DyLan project, including its structure and key terminology. - Enhanced the Pyodide API to include session information in various actions, improving the user interface and feedback during parsing. - Updated GUI components to reflect session details and interpretation counts, ensuring users have access to relevant information during interactions.
1 parent 3441c4a commit e9e7fdd

14 files changed

Lines changed: 1435 additions & 365 deletions

‎CONTEXT.md‎

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# DyLan / Dynamic Syntax
2+
3+
Python port of DyLan, an incremental Dynamic Syntax (DS) parser with Type Theory with Records (TTR). The package parses utterances into decorated trees and a word-level derivation DAG, and can induce a DS-TTR lexicon from examples.
4+
5+
## Structure
6+
7+
- `src/dylan/` — parser, tree, DAG, actions, TTR, induction, Flet GUI, Pyodide façade
8+
- `src/dynamicsyntax/` — public package entry (`icp`, bundled grammars)
9+
- `web/` — static Pyodide UI that calls `dylan.pyodide_api` (same `ParseSession` as the Flet app)
10+
- `tests/` — pytest suite
11+
12+
## Language
13+
14+
**DS Tree**:
15+
A decorated Dynamic Syntax tree: node addresses, type and formula labels, and a distinguished pointer.
16+
_Avoid_: parse tree, constituency tree
17+
18+
**DAG tuple**:
19+
One interpretation node in the word-level context DAG; the current tuple is the parser’s live derivation state.
20+
_Avoid_: parse, hypothesis (when you mean this DAG node)
21+
22+
**Viewport**:
23+
The Output pane that shows the DS Tree canvas, not the OS screen or device.
24+
_Avoid_: device, window (when you mean the tree pane)
25+
26+
**Camera**:
27+
The Output pane's scroll position over a natural-size DS Tree. A tree that fits the pane is centred; Fit scrolls a larger tree so its middle is in view.
28+
_Avoid_: scale-to-fit layout, stretch, zoom
29+
30+
**Fit-to-pane**:
31+
Scrolling a natural-size DS Tree so its middle sits in the Viewport. Node boxes stay at their intrinsic size.
32+
_Avoid_: zoom, fit-to-viewport layout
33+
34+
**Interpretation**:
35+
One DAG tuple in the sequence reached by stepping the parser after a sentence, shown as an index in 1 / N.
36+
_Avoid_: step, hypothesis, reading
37+
38+
**Info**:
39+
The live session card (how-to plus grammar path, last action, warnings, pointer, current DAG tuple).
40+
_Avoid_: help pane, loguru log
41+
42+
**Logs**:
43+
The append-only event history (grammar-load warnings, parse/step lines).
44+
_Avoid_: loguru log, Info
45+

‎src/dylan/formula/manim/tree_scene.py‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,17 @@ def _point(x_px: float, y_px: float, *, width_px: float, height_px: float) -> tu
1818

1919

2020
def serialize_tree(tree: Tree, *, width_px: float = 1000.0, height_px: float = 640.0) -> dict[str, Any]:
21-
"""Return JSON-friendly node/edge layout data for *tree*."""
22-
layout = compute_tree_layout(tree, width_px, height_px, font_size=12.0)
21+
"""Return JSON-friendly node/edge layout data for *tree*.
22+
23+
Mapping uses the natural layout bounding box. *width_px* / *height_px* are
24+
unused fallbacks when that box is empty.
25+
"""
26+
layout = compute_tree_layout(tree, font_size=12.0, label_density="full")
27+
map_w = float(layout.canvas_w) if layout.canvas_w > 1.0 else float(width_px)
28+
map_h = float(layout.canvas_h) if layout.canvas_h > 1.0 else float(height_px)
2329
nodes: list[dict[str, Any]] = []
2430
for node in layout.nodes:
25-
x, y = _point(node.cx, node.cy, width_px=width_px, height_px=height_px)
31+
x, y = _point(node.cx, node.cy, width_px=map_w, height_px=map_h)
2632
nodes.append(
2733
{
2834
"id": node.addr.address or "root",
@@ -35,8 +41,8 @@ def serialize_tree(tree: Tree, *, width_px: float = 1000.0, height_px: float = 6
3541
)
3642
edges: list[dict[str, Any]] = []
3743
for edge in layout.edges:
38-
x1, y1 = _point(edge.x1, edge.y1, width_px=width_px, height_px=height_px)
39-
x2, y2 = _point(edge.x2, edge.y2, width_px=width_px, height_px=height_px)
44+
x1, y1 = _point(edge.x1, edge.y1, width_px=map_w, height_px=map_h)
45+
x2, y2 = _point(edge.x2, edge.y2, width_px=map_w, height_px=map_h)
4046
edges.append({"x1": x1, "y1": y1, "x2": x2, "y2": y2, "style": edge.style})
4147
return {"nodes": nodes, "edges": edges}
4248

0 commit comments

Comments
 (0)