calliope-ts 0.0.4 → 0.1.0

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.
Files changed (183) hide show
  1. package/README.md +69 -3
  2. package/dist/calliope/bracketing.d.ts.map +1 -1
  3. package/dist/calliope/bracketing.js +59 -5
  4. package/dist/calliope/deps.d.ts +5 -1
  5. package/dist/calliope/deps.d.ts.map +1 -1
  6. package/dist/calliope/deps.js +53 -3
  7. package/dist/calliope/engine.d.ts.map +1 -1
  8. package/dist/calliope/engine.js +6 -1
  9. package/dist/calliope/relstress.d.ts.map +1 -1
  10. package/dist/calliope/relstress.js +411 -15
  11. package/dist/calliope/syntax.d.ts +33 -0
  12. package/dist/calliope/syntax.d.ts.map +1 -1
  13. package/dist/calliope/syntax.js +199 -0
  14. package/dist/data/en_common_words.json +1 -0
  15. package/dist/display.d.ts +15 -1
  16. package/dist/display.d.ts.map +1 -1
  17. package/dist/display.js +112 -10
  18. package/dist/fabbhalle.d.ts +54 -0
  19. package/dist/fabbhalle.d.ts.map +1 -0
  20. package/dist/fabbhalle.js +404 -0
  21. package/dist/index.d.ts.map +1 -1
  22. package/dist/index.js +86 -33
  23. package/dist/phonological.d.ts.map +1 -1
  24. package/dist/phonological.js +7 -1
  25. package/dist/rewriteEn.d.ts +14 -0
  26. package/dist/rewriteEn.d.ts.map +1 -0
  27. package/dist/rewriteEn.js +392 -0
  28. package/dist/rhyme.d.ts +35 -3
  29. package/dist/rhyme.d.ts.map +1 -1
  30. package/dist/rhyme.js +176 -11
  31. package/dist/russian/accentuator.d.ts +31 -0
  32. package/dist/russian/accentuator.d.ts.map +1 -0
  33. package/dist/russian/accentuator.js +546 -0
  34. package/dist/russian/collocations.d.ts +7 -0
  35. package/dist/russian/collocations.d.ts.map +1 -0
  36. package/dist/russian/collocations.js +38 -0
  37. package/dist/russian/compounds.d.ts +6 -0
  38. package/dist/russian/compounds.d.ts.map +1 -0
  39. package/dist/russian/compounds.js +81 -0
  40. package/dist/russian/download.d.ts +23 -0
  41. package/dist/russian/download.d.ts.map +1 -0
  42. package/dist/russian/download.js +117 -0
  43. package/dist/russian/engine.d.ts +6 -0
  44. package/dist/russian/engine.d.ts.map +1 -0
  45. package/dist/russian/engine.js +1424 -0
  46. package/dist/russian/parser.d.ts +8 -0
  47. package/dist/russian/parser.d.ts.map +1 -0
  48. package/dist/russian/parser.js +92 -0
  49. package/dist/russian/paths.d.ts +55 -0
  50. package/dist/russian/paths.d.ts.map +1 -0
  51. package/dist/russian/paths.js +114 -0
  52. package/dist/russian/rewrite.d.ts +6 -0
  53. package/dist/russian/rewrite.d.ts.map +1 -0
  54. package/dist/russian/rewrite.js +400 -0
  55. package/dist/russian/rhyme.d.ts +18 -0
  56. package/dist/russian/rhyme.d.ts.map +1 -0
  57. package/dist/russian/rhyme.js +230 -0
  58. package/dist/russian/syllabifier.d.ts +14 -0
  59. package/dist/russian/syllabifier.d.ts.map +1 -0
  60. package/dist/russian/syllabifier.js +475 -0
  61. package/dist/russian/types.d.ts +94 -0
  62. package/dist/russian/types.d.ts.map +1 -0
  63. package/dist/russian/types.js +27 -0
  64. package/dist/scandroidNative/constants.d.ts +16 -0
  65. package/dist/scandroidNative/constants.d.ts.map +1 -0
  66. package/dist/scandroidNative/constants.js +60 -0
  67. package/dist/scandroidNative/deduceParameters.d.ts +16 -0
  68. package/dist/scandroidNative/deduceParameters.d.ts.map +1 -0
  69. package/dist/scandroidNative/deduceParameters.js +69 -0
  70. package/dist/scandroidNative/dictionary-data.d.ts +2 -0
  71. package/dist/scandroidNative/dictionary-data.d.ts.map +1 -0
  72. package/dist/scandroidNative/dictionary-data.js +744 -0
  73. package/dist/scandroidNative/dictionary.d.ts +12 -0
  74. package/dist/scandroidNative/dictionary.d.ts.map +1 -0
  75. package/dist/scandroidNative/dictionary.js +50 -0
  76. package/dist/scandroidNative/engine.d.ts +41 -0
  77. package/dist/scandroidNative/engine.d.ts.map +1 -0
  78. package/dist/scandroidNative/engine.js +119 -0
  79. package/dist/scandroidNative/machine.d.ts +93 -0
  80. package/dist/scandroidNative/machine.d.ts.map +1 -0
  81. package/dist/scandroidNative/machine.js +795 -0
  82. package/dist/scandroidNative/positioner.d.ts +32 -0
  83. package/dist/scandroidNative/positioner.d.ts.map +1 -0
  84. package/dist/scandroidNative/positioner.js +208 -0
  85. package/dist/scandroidNative/syllabizer.d.ts +3 -0
  86. package/dist/scandroidNative/syllabizer.d.ts.map +1 -0
  87. package/dist/scandroidNative/syllabizer.js +215 -0
  88. package/dist/scandroidNative/utilities.d.ts +37 -0
  89. package/dist/scandroidNative/utilities.d.ts.map +1 -0
  90. package/dist/scandroidNative/utilities.js +86 -0
  91. package/dist/scansion.d.ts.map +1 -1
  92. package/dist/scansion.js +118 -14
  93. package/dist/stress.d.ts +1 -0
  94. package/dist/stress.d.ts.map +1 -1
  95. package/dist/stress.js +502 -42
  96. package/dist/types.d.ts +3 -0
  97. package/dist/types.d.ts.map +1 -1
  98. package/package.json +27 -6
  99. package/tools/fetch-russian-data.mjs +30 -0
  100. package/webapp/public/app.js +2418 -0
  101. package/webapp/public/assets/GithubLogo.png +0 -0
  102. package/webapp/public/assets/NPM2.png +0 -0
  103. package/webapp/public/assets/fonts/MurenaBold-webfont.woff2 +0 -0
  104. package/webapp/public/assets/fonts/MurenaItalic-webfont.woff2 +0 -0
  105. package/webapp/public/assets/fonts/MurenaRegular-webfont.woff2 +0 -0
  106. package/webapp/public/assets/fonts/Myra_4F_Caps_Bold-webfont.woff2 +0 -0
  107. package/webapp/public/assets/fonts/SinkinSans-700Bold.otf +0 -0
  108. package/webapp/public/assets/fonts/butterflies.ttf +0 -0
  109. package/webapp/public/assets/fonts/midcase_blackline-webfont.woff2 +0 -0
  110. package/webapp/public/assets/fonts/neueral-bold-webfont.woff2 +0 -0
  111. package/webapp/public/assets/fonts/neueral-regular-webfont.woff2 +0 -0
  112. package/webapp/public/assets/fonts/popelka-webfont.woff2 +0 -0
  113. package/webapp/public/assets/fonts/vremenagrotesk-webfont.woff +0 -0
  114. package/webapp/public/assets/fonts/wicky_javick_bold-webfont.woff2 +0 -0
  115. package/webapp/public/assets/logos/Logo_Var_10_Celtic_Knot_SVG.svg +116 -0
  116. package/webapp/public/assets/logos/Logo_Var_11_Graph_SVG.svg +313 -0
  117. package/webapp/public/assets/logos/Logo_Var_12_Limacon_Knot_SVG.svg +3942 -0
  118. package/webapp/public/assets/logos/Logo_Var_13_Crescents_SVG.svg +1030 -0
  119. package/webapp/public/assets/logos/Logo_Var_1_Spiral_SVG.svg +1491 -0
  120. package/webapp/public/assets/logos/Logo_Var_2_Tunnel_SVG.svg +12 -0
  121. package/webapp/public/assets/logos/Logo_Var_3_Triskelion_SVG.svg +10 -0
  122. package/webapp/public/assets/logos/Logo_Var_4_Quinquetra_PNG.png +0 -0
  123. package/webapp/public/assets/logos/Logo_Var_5_Penrose_Pentagram_SVG.svg +37 -0
  124. package/webapp/public/assets/logos/Logo_Var_6_Triskelion2_SVG.svg +10 -0
  125. package/webapp/public/assets/logos/Logo_Var_7_SixfoldSpirals_SVG.svg +20 -0
  126. package/webapp/public/assets/logos/Logo_Var_8_Radial_Labyrinth_SVG.svg +163 -0
  127. package/webapp/public/assets/logos/Logo_Var_9_Radial_Labyrinth_2_SVG.svg +106 -0
  128. package/webapp/public/index.html +316 -0
  129. package/webapp/public/styles.css +1114 -0
  130. package/webapp/server.mjs +680 -0
  131. package/src/caesura.ts +0 -201
  132. package/src/calliope/boundaries.ts +0 -190
  133. package/src/calliope/bracketing.ts +0 -390
  134. package/src/calliope/deps.ts +0 -160
  135. package/src/calliope/engine.ts +0 -77
  136. package/src/calliope/feats.ts +0 -46
  137. package/src/calliope/names.ts +0 -44
  138. package/src/calliope/postag.ts +0 -253
  139. package/src/calliope/prosodic.ts +0 -262
  140. package/src/calliope/relstress.ts +0 -645
  141. package/src/calliope/stressrules.ts +0 -147
  142. package/src/calliope/syntax.ts +0 -218
  143. package/src/calliope/udpos.ts +0 -152
  144. package/src/calliope_src_contents.md +0 -19049
  145. package/src/clio/caesura.ts +0 -145
  146. package/src/clio/depfix.ts +0 -88
  147. package/src/clio/display.ts +0 -1042
  148. package/src/clio/engine.ts +0 -38
  149. package/src/clio/parser.ts +0 -845
  150. package/src/clio/phonological.ts +0 -849
  151. package/src/clio/phrasestress.ts +0 -108
  152. package/src/clio/pipeline.ts +0 -154
  153. package/src/clio/rhyme.ts +0 -740
  154. package/src/clio/scandroid.ts +0 -434
  155. package/src/clio/scansion.ts +0 -1130
  156. package/src/clio/semantics.ts +0 -134
  157. package/src/clio/stress.ts +0 -1731
  158. package/src/clio/tagfix.ts +0 -104
  159. package/src/depfix.ts +0 -88
  160. package/src/display.ts +0 -1138
  161. package/src/engine.ts +0 -22
  162. package/src/index.ts +0 -690
  163. package/src/parser.ts +0 -501
  164. package/src/phonological.ts +0 -917
  165. package/src/phrasestress.ts +0 -108
  166. package/src/rhyme.ts +0 -748
  167. package/src/scandroid.ts +0 -434
  168. package/src/scansion.ts +0 -1174
  169. package/src/semantics.ts +0 -134
  170. package/src/stress.ts +0 -2111
  171. package/src/tagfix.ts +0 -104
  172. package/src/types.ts +0 -265
  173. package/tests/DataForHayesLinesOnly.txt +0 -364
  174. package/tests/DataForHayesStressSymbolsRevised.txt +0 -728
  175. package/tests/basic.test.ts +0 -1102
  176. package/tests/bench-hayes.mjs +0 -72
  177. package/tests/epg64.meter.train.txt +0 -8139
  178. package/tests/litlab-sample-2016.txt +0 -1738
  179. package/tests/prosodic.meter.train.txt +0 -13192
  180. package/tests/wagner-stress.test.ts +0 -188
  181. package/tsconfig.json +0 -29
  182. package/vitest.config.d.ts +0 -2
  183. package/vitest.config.js +0 -14
@@ -1,134 +0,0 @@
1
- // semantics.ts — Prominence signals mined from the dependency parse + POS.
2
- //
3
- // Dependency roles ARE the semantic layer: NSUBJ=agent, DOBJ/IOBJ=patient/
4
- // recipient, OBL/ADVMOD/ADVCL=peripheral, PRP$=possessor, INTJ/DISCOURSE=
5
- // address. A flat POS floor crushes function words that these configurations
6
- // reveal to be prominent — a STRANDED preposition ("what are you waiting FOR"),
7
- // a CONTRASTIVE possessive ("thy choice, not mine"), a VOCATIVE. These
8
- // detectors recover that prominence from observable structure only (no semantic
9
- // guessing, no cross-poem givenness). They are consumed by the relativiser
10
- // (stress.ts) as targeted floor RAISES, and by the nuclear pass (Phase 4).
11
-
12
- import { ClsWord } from '../types.js';
13
- import { isPunctuation } from './parser.js';
14
-
15
- /** True if some other token has `word` as its dependency governor (i.e. word
16
- * has a complement/dependent of its own). */
17
- function hasDependent(word: ClsWord, words: ClsWord[]): boolean {
18
- for (const w of words) {
19
- if (w !== word && w.dependency && w.dependency.governor === word) return true;
20
- }
21
- return false;
22
- }
23
-
24
- /** Last non-punctuation token index in the sentence at/after `from`? */
25
- function isClauseFinal(word: ClsWord, words: ClsWord[]): boolean {
26
- const idx = words.indexOf(word);
27
- if (idx < 0) return false;
28
- for (let k = idx + 1; k < words.length; k++) {
29
- if (!isPunctuation(words[k].lexicalClass)) return false;
30
- }
31
- return true;
32
- }
33
-
34
- /**
35
- * A STRANDED preposition: an IN preposition whose complement has been extracted
36
- * (wh-movement / relativisation / topicalisation), so it governs no object and
37
- * sits clause-finally — "what are you waiting FOR", "…what you stare AT". Such
38
- * a preposition bears stress (it is not the reducible proclitic of "in the
39
- * house"). Conservative: IN only (infinitival TO is excluded — "I want to go"
40
- * is not stranding), no dependent, and clause-final (the canonical strand site).
41
- */
42
- export function isStrandedPreposition(word: ClsWord, words: ClsWord[]): boolean {
43
- if (word.lexicalClass !== 'IN') return false;
44
- if (hasDependent(word, words)) return false; // has a complement → ordinary preposition
45
- return isClauseFinal(word, words);
46
- }
47
-
48
- /** Absolute / elliptical possessive pronouns used as the contrasted element. */
49
- const ABSOLUTE_POSSESSIVES = new Set([
50
- 'mine', 'thine', 'yours', 'hers', 'ours', 'theirs', 'his',
51
- ]);
52
- const CONTRAST_MARKERS = new Set(['not', 'but', 'nor']);
53
-
54
- /**
55
- * A CONTRASTIVE possessive: a possessive determiner (PRP$: thy/my/your/her…)
56
- * in the elliptical contrast frame "X's … not/but MINE" — the contrast lifts
57
- * the possessor out of reduction ("it was THY choice, not mine"). Tight by
58
- * construction: requires a contrast marker (not/but/nor) adjacent to an
59
- * absolute possessive somewhere in the clause, so an ordinary unfocused
60
- * possessive ("I lost my way") is left alone.
61
- */
62
- export function isContrastivePossessive(word: ClsWord, words: ClsWord[]): boolean {
63
- if (word.lexicalClass !== 'PRP$') return false;
64
- for (let i = 0; i + 1 < words.length; i++) {
65
- const a = words[i].word.toLowerCase();
66
- const b = words[i + 1].word.toLowerCase().replace(/['’]/g, '');
67
- if (CONTRAST_MARKERS.has(a) && ABSOLUTE_POSSESSIVES.has(b)) return true;
68
- }
69
- return false;
70
- }
71
-
72
- /** Finite auxiliaries / modals whose appearance before a subject pronoun marks
73
- * subject-aux inversion. */
74
- const INVERSION_AUX = new Set(['MD', 'VBP', 'VBZ', 'VBD']);
75
-
76
- /**
77
- * A fronted DEICTIC LOCATIVE "there"/"here" in locative inversion — "THERE
78
- * could I marvel", "HERE could I rest". FinNLP mis-tags the fronted locative
79
- * as existential (EX / expl) or reduces it as a discourse adverb, flattening it
80
- * to 'w'; but a fronted locative that triggers subject-aux inversion (an
81
- * aux/modal immediately followed by a subject pronoun) is a stressed deictic
82
- * focus, NOT the reduced existential of "there IS a house" (no inversion) or
83
- * the presentational "there LIVED a king" (verb + NP, no inversion).
84
- */
85
- export function isDeicticLocative(word: ClsWord, words: ClsWord[]): boolean {
86
- const lemma = word.word.toLowerCase().replace(/['’]/g, '');
87
- if (lemma !== 'there' && lemma !== 'here') return false;
88
- const idx = words.indexOf(word);
89
- // must be the first non-punctuation token (fronted)
90
- let first = -1;
91
- for (let i = 0; i < words.length; i++) {
92
- if (!isPunctuation(words[i].lexicalClass)) { first = i; break; }
93
- }
94
- if (idx !== first) return false;
95
- // subject-aux inversion: <there/here> <aux|modal> <subject pronoun>
96
- const aux = words[idx + 1];
97
- const subj = words[idx + 2];
98
- return !!(aux && subj && INVERSION_AUX.has(aux.lexicalClass) && subj.lexicalClass === 'PRP');
99
- }
100
-
101
- /**
102
- * Imperative clause: the ROOT is a base-form verb (VB) with no overt subject
103
- * (no NSUBJ dependent) — "Tell me…", "Do not go…". Used by the nuclear pass:
104
- * the accent falls on the verb / its object, not on a (dropped) subject, and an
105
- * imperative-clause vocative is a direct address.
106
- */
107
- export function isImperativeClause(words: ClsWord[]): boolean {
108
- const root = words.find(w => w.dependency && w.dependency.dependentType === 'root');
109
- if (!root) return false;
110
- if (root.lexicalClass !== 'VB' && root.lexicalClass !== 'VBP') return false;
111
- for (const w of words) {
112
- if (w.dependency && w.dependency.governor === root
113
- && /nsubj/i.test(w.dependency.dependentType)) return false;
114
- }
115
- return true;
116
- }
117
-
118
- /**
119
- * A VOCATIVE (direct address): a noun tagged DISCOURSE/INTJ/DEP and set off by
120
- * adjacent punctuation (a comma or "!"), in a clause that is imperative or
121
- * subject-less — "Sing, O GODDESS…", "blow, BUGLE, blow". Conservative: the
122
- * noun must be comma/!-adjacent so an ordinary argument noun is not swept in.
123
- */
124
- export function isVocative(word: ClsWord, words: ClsWord[]): boolean {
125
- if (!/^(NN|NNS|NNP|NNPS)$/.test(word.lexicalClass)) return false;
126
- const role = word.dependency?.dependentType ?? '';
127
- if (!/discourse|intj|dep|vocative/i.test(role)) return false;
128
- const idx = words.indexOf(word);
129
- const prev = idx > 0 ? words[idx - 1] : null;
130
- const next = idx + 1 < words.length ? words[idx + 1] : null;
131
- const commaAdjacent =
132
- (prev && /^[,!]$/.test(prev.word)) || (next && /^[,!]$/.test(next.word));
133
- return !!commaAdjacent && isImperativeClause(words);
134
- }