calliope-ts 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/tsconfig.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2022",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
7
+ "outDir": "./dist",
8
+ "rootDir": "./src",
9
+ "strict": true,
10
+ "esModuleInterop": true,
11
+ "skipLibCheck": true,
12
+ "forceConsistentCasingInFileNames": true,
13
+ "resolveJsonModule": true,
14
+ "declaration": true,
15
+ "declarationMap": true,
16
+ "allowJs": true,
17
+ "allowSyntheticDefaultImports": true,
18
+ "paths": {
19
+ "@/*": ["./*"]
20
+ }
21
+ },
22
+ "include": [
23
+ "src"
24
+ ],
25
+ "exclude": [
26
+ "node_modules",
27
+ "dist"
28
+ ]
29
+ }
@@ -0,0 +1,2 @@
1
+ declare const _default: import("vite").UserConfig;
2
+ export default _default;
@@ -0,0 +1,14 @@
1
+ // vitest.config.ts
2
+ import { defineConfig } from 'vitest/config';
3
+ export default defineConfig({
4
+ test: {
5
+ globals: true,
6
+ environment: 'node',
7
+ include: ['tests/**/*.test.ts'],
8
+ testTimeout: 10000,
9
+ deps: {
10
+ // required for esm packages like finnlp
11
+ interopDefault: true,
12
+ },
13
+ },
14
+ });
@@ -0,0 +1,15 @@
1
+ // vitest.config.ts
2
+ import { defineConfig } from 'vitest/config';
3
+
4
+ export default defineConfig({
5
+ test: {
6
+ globals: true,
7
+ environment: 'node',
8
+ include: ['tests/**/*.test.ts'],
9
+ testTimeout: 10000,
10
+ deps: {
11
+ // required for esm packages like finnlp
12
+ interopDefault: true,
13
+ },
14
+ },
15
+ });
@@ -1,8 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(npx vitest *)",
5
- "Bash(npx ts-node *)"
6
- ]
7
- }
8
- }
@@ -1,74 +0,0 @@
1
- ---
2
- name: calliope-ts
3
- description: Phonological-syntactic scansion of English poetry implementing McAleese (2008) methodology. Use when working on Calliope TS — stress assignment, meter detection, prosodic hierarchy, FinNLP parsing, CMU pronouncing lookup. Triggers: calliope, scansion, poetry meter, iambic, trochaic, anapestic, dactylic, nuclear stress, compound stress, prosodic hierarchy, FinNLP, en-pos, en-parse.
4
- ---
5
-
6
- # Calliope TS — Poetry Scansion Toolkit
7
-
8
- ## Core Principle
9
-
10
- **Phonological scansion operates on PHONES (sound units), not graphemes (letter units).** Syntactic parsing (FinNLP) is correctly graphemic. Lexical stress lookup must use phonemic output from CMU dictionary via `Nounsing-Pro`.
11
-
12
- ## Pipeline (7 steps per McAleese 2008)
13
-
14
- 1. **Parse** (`parser.ts`) — FinNLP → ClsDocument with words, deps, POS
15
- 2. **Lexical Stress** (`stress.ts`) — CMU dict lookup per word via `Nounsing-Pro` (phonemes → syllable stress)
16
- 3. **Phrase-Level Stress** — Compound + Nuclear + Relative mapping (0→w, 1→n, 2+→s)
17
- 4. **Prosodic Hierarchy** (`phonological.ts`) — CP → PP → IU (Selkirk)
18
- 5. **Key-Stress Extraction** (`scansion.ts`) — Right-edge extraction per unit level
19
- 6. **Metre Scoring** — 8 metres + tie-breaking, weighted by unit importance
20
- 7. **Scansion Assembly** — Align strong stresses to metrical beats, place foot boundaries
21
-
22
- ## Stress Symbols
23
-
24
- | Symbol | Level | Mapping |
25
- |--------|-------|---------|
26
- | w | Weakest | Numeric 0 |
27
- | n | Low | Numeric 1 |
28
- | m | Moderate/Secondary | Numeric 2 |
29
- | s | Strongest/Primary | Numeric 3+ |
30
- | x | Metrically insignificant | Key-stress masking |
31
- | W | Weak metrical position | |
32
- | S | Strong metrical position | |
33
-
34
- ## Key Architectural Decisions
35
-
36
- ### Nuclear Stress (2026-05-07 fix)
37
- - **Old**: 5-level right-to-left gradient (5→4→3→2→1) — killed triple meter detection
38
- - **New**: Only +1 boost for rightmost content word. `lexicalStress` field preserves CMU values for meter scoring
39
- - Meter detection uses `lexicalStress`, NOT nuclear-stress-modified values
40
-
41
- ### Contraction Handling (2026-05-07 fix)
42
- - FinNLP `en-norm` deencliticizes: `we'll` → `we` + `will` (2 tokens)
43
- - Post-parse re-merging restores contracted form as 1 phonetic unit
44
- - 41 contraction patterns handled (pre-scan → parse → re-merge)
45
-
46
- ### Punctuation Filtering
47
- - Punctuation tokens (`,` `.` `?` `!` `;` `:` `--` `...`) filtered from syllable arrays
48
- - Must NOT appear in scansion strings
49
-
50
- ### Display (per-syllable)
51
- - All display functions operate per-SYLLABLE (not per-word)
52
- - 3-syllable word = 3 independently colored syllables
53
-
54
- ## Known Gaps (Phase 5/6)
55
-
56
- - **Metrical promotion**: Function words in strong positions not promoted — nuclear stress used as proxy
57
- - **Contextual disambiguation**: Lines like "Burnt after them" need surrounding context for meter
58
- - **Anacrusis detection**: First weak syllable not properly excluded from foot count
59
- - **Elision**: Vowel merging across word boundaries not implemented
60
- - Full McAleese expert baseline matching (~65% target)
61
-
62
- ## Test Commands
63
-
64
- ```bash
65
- npm run build # Compile TypeScript
66
- npx tsc --noEmit # Typecheck
67
- npx vitest run tests/basic.test.ts # Run all tests
68
- ```
69
-
70
- ## Dependencies
71
-
72
- - **finnlp** — Penn-treebank POS + Universal Dependency parsing
73
- - **nounsing-pro** — CMU dictionary lexical stress, and morphological/phonological nuance lookup
74
- - Never assume other libraries without checking package.json