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.
- package/README.md +69 -3
- package/dist/calliope/bracketing.d.ts.map +1 -1
- package/dist/calliope/bracketing.js +59 -5
- package/dist/calliope/deps.d.ts +5 -1
- package/dist/calliope/deps.d.ts.map +1 -1
- package/dist/calliope/deps.js +53 -3
- package/dist/calliope/engine.d.ts.map +1 -1
- package/dist/calliope/engine.js +6 -1
- package/dist/calliope/relstress.d.ts.map +1 -1
- package/dist/calliope/relstress.js +411 -15
- package/dist/calliope/syntax.d.ts +33 -0
- package/dist/calliope/syntax.d.ts.map +1 -1
- package/dist/calliope/syntax.js +199 -0
- package/dist/data/en_common_words.json +1 -0
- package/dist/display.d.ts +15 -1
- package/dist/display.d.ts.map +1 -1
- package/dist/display.js +112 -10
- package/dist/fabbhalle.d.ts +54 -0
- package/dist/fabbhalle.d.ts.map +1 -0
- package/dist/fabbhalle.js +404 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +86 -33
- package/dist/phonological.d.ts.map +1 -1
- package/dist/phonological.js +7 -1
- package/dist/rewriteEn.d.ts +14 -0
- package/dist/rewriteEn.d.ts.map +1 -0
- package/dist/rewriteEn.js +392 -0
- package/dist/rhyme.d.ts +35 -3
- package/dist/rhyme.d.ts.map +1 -1
- package/dist/rhyme.js +176 -11
- package/dist/russian/accentuator.d.ts +31 -0
- package/dist/russian/accentuator.d.ts.map +1 -0
- package/dist/russian/accentuator.js +546 -0
- package/dist/russian/collocations.d.ts +7 -0
- package/dist/russian/collocations.d.ts.map +1 -0
- package/dist/russian/collocations.js +38 -0
- package/dist/russian/compounds.d.ts +6 -0
- package/dist/russian/compounds.d.ts.map +1 -0
- package/dist/russian/compounds.js +81 -0
- package/dist/russian/download.d.ts +23 -0
- package/dist/russian/download.d.ts.map +1 -0
- package/dist/russian/download.js +117 -0
- package/dist/russian/engine.d.ts +6 -0
- package/dist/russian/engine.d.ts.map +1 -0
- package/dist/russian/engine.js +1424 -0
- package/dist/russian/parser.d.ts +8 -0
- package/dist/russian/parser.d.ts.map +1 -0
- package/dist/russian/parser.js +92 -0
- package/dist/russian/paths.d.ts +55 -0
- package/dist/russian/paths.d.ts.map +1 -0
- package/dist/russian/paths.js +114 -0
- package/dist/russian/rewrite.d.ts +6 -0
- package/dist/russian/rewrite.d.ts.map +1 -0
- package/dist/russian/rewrite.js +400 -0
- package/dist/russian/rhyme.d.ts +18 -0
- package/dist/russian/rhyme.d.ts.map +1 -0
- package/dist/russian/rhyme.js +230 -0
- package/dist/russian/syllabifier.d.ts +14 -0
- package/dist/russian/syllabifier.d.ts.map +1 -0
- package/dist/russian/syllabifier.js +475 -0
- package/dist/russian/types.d.ts +94 -0
- package/dist/russian/types.d.ts.map +1 -0
- package/dist/russian/types.js +27 -0
- package/dist/scandroidNative/constants.d.ts +16 -0
- package/dist/scandroidNative/constants.d.ts.map +1 -0
- package/dist/scandroidNative/constants.js +60 -0
- package/dist/scandroidNative/deduceParameters.d.ts +16 -0
- package/dist/scandroidNative/deduceParameters.d.ts.map +1 -0
- package/dist/scandroidNative/deduceParameters.js +69 -0
- package/dist/scandroidNative/dictionary-data.d.ts +2 -0
- package/dist/scandroidNative/dictionary-data.d.ts.map +1 -0
- package/dist/scandroidNative/dictionary-data.js +744 -0
- package/dist/scandroidNative/dictionary.d.ts +12 -0
- package/dist/scandroidNative/dictionary.d.ts.map +1 -0
- package/dist/scandroidNative/dictionary.js +50 -0
- package/dist/scandroidNative/engine.d.ts +41 -0
- package/dist/scandroidNative/engine.d.ts.map +1 -0
- package/dist/scandroidNative/engine.js +119 -0
- package/dist/scandroidNative/machine.d.ts +93 -0
- package/dist/scandroidNative/machine.d.ts.map +1 -0
- package/dist/scandroidNative/machine.js +795 -0
- package/dist/scandroidNative/positioner.d.ts +32 -0
- package/dist/scandroidNative/positioner.d.ts.map +1 -0
- package/dist/scandroidNative/positioner.js +208 -0
- package/dist/scandroidNative/syllabizer.d.ts +3 -0
- package/dist/scandroidNative/syllabizer.d.ts.map +1 -0
- package/dist/scandroidNative/syllabizer.js +215 -0
- package/dist/scandroidNative/utilities.d.ts +37 -0
- package/dist/scandroidNative/utilities.d.ts.map +1 -0
- package/dist/scandroidNative/utilities.js +86 -0
- package/dist/scansion.d.ts.map +1 -1
- package/dist/scansion.js +118 -14
- package/dist/stress.d.ts +1 -0
- package/dist/stress.d.ts.map +1 -1
- package/dist/stress.js +502 -42
- package/dist/types.d.ts +3 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +27 -6
- package/tools/fetch-russian-data.mjs +30 -0
- package/webapp/public/app.js +2418 -0
- package/webapp/public/assets/GithubLogo.png +0 -0
- package/webapp/public/assets/NPM2.png +0 -0
- package/webapp/public/assets/fonts/MurenaBold-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/MurenaItalic-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/MurenaRegular-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/Myra_4F_Caps_Bold-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/SinkinSans-700Bold.otf +0 -0
- package/webapp/public/assets/fonts/butterflies.ttf +0 -0
- package/webapp/public/assets/fonts/midcase_blackline-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/neueral-bold-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/neueral-regular-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/popelka-webfont.woff2 +0 -0
- package/webapp/public/assets/fonts/vremenagrotesk-webfont.woff +0 -0
- package/webapp/public/assets/fonts/wicky_javick_bold-webfont.woff2 +0 -0
- package/webapp/public/assets/logos/Logo_Var_10_Celtic_Knot_SVG.svg +116 -0
- package/webapp/public/assets/logos/Logo_Var_11_Graph_SVG.svg +313 -0
- package/webapp/public/assets/logos/Logo_Var_12_Limacon_Knot_SVG.svg +3942 -0
- package/webapp/public/assets/logos/Logo_Var_13_Crescents_SVG.svg +1030 -0
- package/webapp/public/assets/logos/Logo_Var_1_Spiral_SVG.svg +1491 -0
- package/webapp/public/assets/logos/Logo_Var_2_Tunnel_SVG.svg +12 -0
- package/webapp/public/assets/logos/Logo_Var_3_Triskelion_SVG.svg +10 -0
- package/webapp/public/assets/logos/Logo_Var_4_Quinquetra_PNG.png +0 -0
- package/webapp/public/assets/logos/Logo_Var_5_Penrose_Pentagram_SVG.svg +37 -0
- package/webapp/public/assets/logos/Logo_Var_6_Triskelion2_SVG.svg +10 -0
- package/webapp/public/assets/logos/Logo_Var_7_SixfoldSpirals_SVG.svg +20 -0
- package/webapp/public/assets/logos/Logo_Var_8_Radial_Labyrinth_SVG.svg +163 -0
- package/webapp/public/assets/logos/Logo_Var_9_Radial_Labyrinth_2_SVG.svg +106 -0
- package/webapp/public/index.html +316 -0
- package/webapp/public/styles.css +1114 -0
- package/webapp/server.mjs +680 -0
- package/src/caesura.ts +0 -201
- package/src/calliope/boundaries.ts +0 -190
- package/src/calliope/bracketing.ts +0 -390
- package/src/calliope/deps.ts +0 -160
- package/src/calliope/engine.ts +0 -77
- package/src/calliope/feats.ts +0 -46
- package/src/calliope/names.ts +0 -44
- package/src/calliope/postag.ts +0 -253
- package/src/calliope/prosodic.ts +0 -262
- package/src/calliope/relstress.ts +0 -645
- package/src/calliope/stressrules.ts +0 -147
- package/src/calliope/syntax.ts +0 -218
- package/src/calliope/udpos.ts +0 -152
- package/src/calliope_src_contents.md +0 -19049
- package/src/clio/caesura.ts +0 -145
- package/src/clio/depfix.ts +0 -88
- package/src/clio/display.ts +0 -1042
- package/src/clio/engine.ts +0 -38
- package/src/clio/parser.ts +0 -845
- package/src/clio/phonological.ts +0 -849
- package/src/clio/phrasestress.ts +0 -108
- package/src/clio/pipeline.ts +0 -154
- package/src/clio/rhyme.ts +0 -740
- package/src/clio/scandroid.ts +0 -434
- package/src/clio/scansion.ts +0 -1130
- package/src/clio/semantics.ts +0 -134
- package/src/clio/stress.ts +0 -1731
- package/src/clio/tagfix.ts +0 -104
- package/src/depfix.ts +0 -88
- package/src/display.ts +0 -1138
- package/src/engine.ts +0 -22
- package/src/index.ts +0 -690
- package/src/parser.ts +0 -501
- package/src/phonological.ts +0 -917
- package/src/phrasestress.ts +0 -108
- package/src/rhyme.ts +0 -748
- package/src/scandroid.ts +0 -434
- package/src/scansion.ts +0 -1174
- package/src/semantics.ts +0 -134
- package/src/stress.ts +0 -2111
- package/src/tagfix.ts +0 -104
- package/src/types.ts +0 -265
- package/tests/DataForHayesLinesOnly.txt +0 -364
- package/tests/DataForHayesStressSymbolsRevised.txt +0 -728
- package/tests/basic.test.ts +0 -1102
- package/tests/bench-hayes.mjs +0 -72
- package/tests/epg64.meter.train.txt +0 -8139
- package/tests/litlab-sample-2016.txt +0 -1738
- package/tests/prosodic.meter.train.txt +0 -13192
- package/tests/wagner-stress.test.ts +0 -188
- package/tsconfig.json +0 -29
- package/vitest.config.d.ts +0 -2
- package/vitest.config.js +0 -14
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Static manifest: every file the Russian pipeline needs, with its exact byte size. */
|
|
2
|
+
export declare const RUSSIAN_DATA_FILES: {
|
|
3
|
+
name: string;
|
|
4
|
+
size: number;
|
|
5
|
+
}[];
|
|
6
|
+
export declare const RUSSIAN_DATA_BASE_URL: string;
|
|
7
|
+
/**
|
|
8
|
+
* Ensure the Russian data assets are present in russianDataWriteDir(),
|
|
9
|
+
* downloading any missing or incorrectly-sized files from
|
|
10
|
+
* RUSSIAN_DATA_BASE_URL. Safe to call repeatedly — once the files are
|
|
11
|
+
* present and correctly sized, this is a cheap no-op. Concurrent callers
|
|
12
|
+
* share the same in-flight run.
|
|
13
|
+
*/
|
|
14
|
+
export declare function ensureRussianData(opts?: {
|
|
15
|
+
force?: boolean;
|
|
16
|
+
onlyFiles?: string[];
|
|
17
|
+
log?: (m: string) => void;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
downloaded: string[];
|
|
20
|
+
skipped: string[];
|
|
21
|
+
dir: string;
|
|
22
|
+
}>;
|
|
23
|
+
//# sourceMappingURL=download.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download.d.ts","sourceRoot":"","sources":["../../src/russian/download.ts"],"names":[],"mappings":"AAYA,wFAAwF;AACxF,eAAO,MAAM,kBAAkB,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,EAmB9D,CAAC;AAEF,eAAO,MAAM,qBAAqB,QAE+C,CAAC;AAyDlF;;;;;;GAMG;AACH,wBAAsB,iBAAiB,CAAC,IAAI,CAAC,EAAE;IAC7C,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;IACrB,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;CAC3B,GAAG,OAAO,CAAC;IAAE,UAAU,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC,CAmCpE"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
// download.ts — on-first-use downloader for the Russian data assets.
|
|
2
|
+
//
|
|
3
|
+
// The Russian pipeline needs ~122 MB of data (SynTagRus UDPipe model +
|
|
4
|
+
// dictionaries) that are NOT bundled in the npm package. This module fetches
|
|
5
|
+
// them from a HuggingFace space into russianDataWriteDir() on first use, then
|
|
6
|
+
// every later call is a cheap no-op once the files are present and correctly
|
|
7
|
+
// sized. Dependency-free: only node: builtins + global fetch (Node 20+).
|
|
8
|
+
import { mkdir, rename, stat, writeFile } from 'node:fs/promises';
|
|
9
|
+
import { resolve } from 'node:path';
|
|
10
|
+
import { russianDataFile, russianDataWriteDir } from './paths.js';
|
|
11
|
+
/** Static manifest: every file the Russian pipeline needs, with its exact byte size. */
|
|
12
|
+
export const RUSSIAN_DATA_FILES = [
|
|
13
|
+
{ name: 'LICENSE.txt', size: 1094 },
|
|
14
|
+
{ name: 'LICENSE_UDpipe_SynTagRus.txt', size: 187 },
|
|
15
|
+
{ name: 'accentuator.bin', size: 31960084 },
|
|
16
|
+
{ name: 'accentuator.json', size: 811 },
|
|
17
|
+
{ name: 'ambiguous_accents.json', size: 3111298 },
|
|
18
|
+
{ name: 'ambiguous_accents2.json', size: 373565 },
|
|
19
|
+
{ name: 'collocations.json', size: 29085 },
|
|
20
|
+
{ name: 'derivation_data.json', size: 4059886 },
|
|
21
|
+
{ name: 'fuzzy_rhymes.json', size: 306 },
|
|
22
|
+
{ name: 'rhymed_words.json', size: 77945 },
|
|
23
|
+
{ name: 'rhyming_dict.json', size: 8651588 },
|
|
24
|
+
{ name: 'russian-syntagrus-ud-2.0-170801.udpipe', size: 45014943 },
|
|
25
|
+
{ name: 'secondary_stress.json', size: 10260274 },
|
|
26
|
+
{ name: 'word_accents.tsv.gz', size: 11107564 },
|
|
27
|
+
{ name: 'word_freq.json', size: 1002126 },
|
|
28
|
+
{ name: 'word_segmentation.json', size: 5087512 },
|
|
29
|
+
{ name: 'yo_by_gram.json', size: 677879 },
|
|
30
|
+
{ name: 'yo_words.json', size: 5988934 },
|
|
31
|
+
];
|
|
32
|
+
export const RUSSIAN_DATA_BASE_URL = process.env.CALLIOPE_RUSSIAN_DATA_URL ??
|
|
33
|
+
'https://huggingface.co/spaces/AlekseyCalvin/cts/resolve/main/src/russian/data';
|
|
34
|
+
const LOG_PREFIX = '[Calliope Russian]';
|
|
35
|
+
function formatBytes(n) {
|
|
36
|
+
return `${(n / (1024 * 1024)).toFixed(1)} MB`;
|
|
37
|
+
}
|
|
38
|
+
/** True if `name` already resolves to a file whose size matches the manifest. */
|
|
39
|
+
async function isPresentAndCorrect(name, expectedSize) {
|
|
40
|
+
const existing = russianDataFile(name);
|
|
41
|
+
if (!existing)
|
|
42
|
+
return false;
|
|
43
|
+
try {
|
|
44
|
+
const st = await stat(existing);
|
|
45
|
+
return st.size === expectedSize;
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
async function downloadOne(name, expectedSize, targetDir, log) {
|
|
52
|
+
const url = `${RUSSIAN_DATA_BASE_URL}/${name}`;
|
|
53
|
+
log(`${LOG_PREFIX} downloading ${name} (${formatBytes(expectedSize)})…`);
|
|
54
|
+
let buf;
|
|
55
|
+
try {
|
|
56
|
+
const res = await fetch(url);
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
throw new Error(`HTTP ${res.status} ${res.statusText}`);
|
|
59
|
+
}
|
|
60
|
+
const ab = await res.arrayBuffer();
|
|
61
|
+
buf = Buffer.from(ab);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
throw new Error(`${LOG_PREFIX} failed to download "${name}" from ${url}: ${err instanceof Error ? err.message : String(err)}\n` +
|
|
65
|
+
`Fix options:\n` +
|
|
66
|
+
` - Check network access to huggingface.co and retry.\n` +
|
|
67
|
+
` - Set CALLIOPE_RUSSIAN_DATA to a directory that already has the Russian data/ files.\n` +
|
|
68
|
+
` - Set CALLIOPE_RUSSIAN_DATA_URL to an alternate mirror hosting the same file set.`);
|
|
69
|
+
}
|
|
70
|
+
if (buf.length !== expectedSize) {
|
|
71
|
+
throw new Error(`${LOG_PREFIX} downloaded "${name}" has the wrong size: expected ${expectedSize} bytes, got ${buf.length} bytes. ` +
|
|
72
|
+
`The remote file may have changed or the transfer was truncated. URL: ${url}`);
|
|
73
|
+
}
|
|
74
|
+
const finalPath = resolve(targetDir, name);
|
|
75
|
+
const tmpPath = `${finalPath}.download-tmp`;
|
|
76
|
+
await writeFile(tmpPath, buf);
|
|
77
|
+
await rename(tmpPath, finalPath);
|
|
78
|
+
}
|
|
79
|
+
let _inFlight = null;
|
|
80
|
+
/**
|
|
81
|
+
* Ensure the Russian data assets are present in russianDataWriteDir(),
|
|
82
|
+
* downloading any missing or incorrectly-sized files from
|
|
83
|
+
* RUSSIAN_DATA_BASE_URL. Safe to call repeatedly — once the files are
|
|
84
|
+
* present and correctly sized, this is a cheap no-op. Concurrent callers
|
|
85
|
+
* share the same in-flight run.
|
|
86
|
+
*/
|
|
87
|
+
export async function ensureRussianData(opts) {
|
|
88
|
+
const force = opts?.force ?? false;
|
|
89
|
+
const log = opts?.log ?? ((m) => console.error(m));
|
|
90
|
+
if (_inFlight && !force)
|
|
91
|
+
return _inFlight;
|
|
92
|
+
const run = (async () => {
|
|
93
|
+
const targetDir = russianDataWriteDir();
|
|
94
|
+
await mkdir(targetDir, { recursive: true });
|
|
95
|
+
const manifest = opts?.onlyFiles
|
|
96
|
+
? RUSSIAN_DATA_FILES.filter(f => opts.onlyFiles.includes(f.name))
|
|
97
|
+
: RUSSIAN_DATA_FILES;
|
|
98
|
+
const downloaded = [];
|
|
99
|
+
const skipped = [];
|
|
100
|
+
for (const { name, size } of manifest) {
|
|
101
|
+
if (!force && (await isPresentAndCorrect(name, size))) {
|
|
102
|
+
skipped.push(name);
|
|
103
|
+
continue;
|
|
104
|
+
}
|
|
105
|
+
await downloadOne(name, size, targetDir, log);
|
|
106
|
+
downloaded.push(name);
|
|
107
|
+
}
|
|
108
|
+
return { downloaded, skipped, dir: targetDir };
|
|
109
|
+
})();
|
|
110
|
+
_inFlight = run;
|
|
111
|
+
try {
|
|
112
|
+
return await run;
|
|
113
|
+
}
|
|
114
|
+
finally {
|
|
115
|
+
_inFlight = null;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RuScansionResult } from './types.js';
|
|
2
|
+
/** Analyze a Russian poem and return the full scansion result. */
|
|
3
|
+
export declare function analyzeRussianPoem(text: string): Promise<RuScansionResult>;
|
|
4
|
+
/** Quick check: is this text Russian? */
|
|
5
|
+
export declare function isRussian(text: string): boolean;
|
|
6
|
+
//# sourceMappingURL=engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/russian/engine.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAEV,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAqsCpB,kEAAkE;AAClE,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAuQhF;AAED,yCAAyC;AACzC,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAI/C"}
|