marlarky 1.0.0 → 1.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/README.md +503 -489
- package/dist/cli.js +139 -139
- package/examples/basic-usage.ts +48 -48
- package/examples/corporate-lexicon.ts +71 -71
- package/examples/lexicons/corporate-min.json +200 -200
- package/examples/with-tracing.ts +85 -85
- package/package.json +70 -70
package/README.md
CHANGED
|
@@ -1,489 +1,503 @@
|
|
|
1
|
-
# Marlarky
|
|
2
|
-
|
|
3
|
-
**Generate syntactically plausible English nonsense, steered by lexicons.**
|
|
4
|
-
|
|
5
|
-
Marlarky is a faker-like library and CLI that produces grammatically correct English text that sounds meaningful but isn't. Perfect for:
|
|
6
|
-
|
|
7
|
-
- Placeholder text generation (like Lorem Ipsum, but in English)
|
|
8
|
-
- Testing and mocking
|
|
9
|
-
- Creative writing prompts
|
|
10
|
-
- Procedural content generation
|
|
11
|
-
- Corporate buzzword bingo
|
|
12
|
-
|
|
13
|
-
## Features
|
|
14
|
-
|
|
15
|
-
- **Syntactically correct** -- Proper grammar, subject-verb agreement, punctuation
|
|
16
|
-
- **Lexicon-driven** -- Guide output with custom vocabularies and style presets
|
|
17
|
-
- **Deterministic** -- Seedable RNG for reproducible output
|
|
18
|
-
- **Configurable** -- Control sentence types, lengths, complexity
|
|
19
|
-
- **Output transforms** -- Pipe text through built-in transforms (Pig Latin, leet speak, pirate, and more)
|
|
20
|
-
- **Traceable** -- Debug mode shows exactly how text was generated
|
|
21
|
-
- **Full CLI** -- Generate text, apply transforms, and validate lexicons from the command line
|
|
22
|
-
- **Zero dependencies** -- Works standalone or with @faker-js/faker
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
npm install marlarky
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
##
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
###
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
marlarky sentence --
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
#
|
|
124
|
-
marlarky
|
|
125
|
-
|
|
126
|
-
#
|
|
127
|
-
marlarky
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
```
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
marlarky
|
|
139
|
-
|
|
140
|
-
#
|
|
141
|
-
marlarky
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
#
|
|
151
|
-
marlarky
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
#
|
|
161
|
-
marlarky sentence --seed 42
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
marlarky sentence --seed 42
|
|
172
|
-
```
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
###
|
|
196
|
-
|
|
197
|
-
```bash
|
|
198
|
-
#
|
|
199
|
-
marlarky
|
|
200
|
-
|
|
201
|
-
#
|
|
202
|
-
marlarky
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
|
223
|
-
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
```
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
"
|
|
304
|
-
"pos": "
|
|
305
|
-
"tags": ["domain:startup"],
|
|
306
|
-
"terms": [
|
|
307
|
-
{ "value": "
|
|
308
|
-
{ "value": "
|
|
309
|
-
{ "value": "pivot", "weight":
|
|
310
|
-
{ "value": "
|
|
311
|
-
]
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
"
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
```
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
1
|
+
# Marlarky
|
|
2
|
+
|
|
3
|
+
**Generate syntactically plausible English nonsense, steered by lexicons.**
|
|
4
|
+
|
|
5
|
+
Marlarky is a faker-like library and CLI that produces grammatically correct English text that sounds meaningful but isn't. Perfect for:
|
|
6
|
+
|
|
7
|
+
- Placeholder text generation (like Lorem Ipsum, but in English)
|
|
8
|
+
- Testing and mocking
|
|
9
|
+
- Creative writing prompts
|
|
10
|
+
- Procedural content generation
|
|
11
|
+
- Corporate buzzword bingo
|
|
12
|
+
|
|
13
|
+
## Features
|
|
14
|
+
|
|
15
|
+
- **Syntactically correct** -- Proper grammar, subject-verb agreement, punctuation
|
|
16
|
+
- **Lexicon-driven** -- Guide output with custom vocabularies and style presets
|
|
17
|
+
- **Deterministic** -- Seedable RNG for reproducible output
|
|
18
|
+
- **Configurable** -- Control sentence types, lengths, complexity
|
|
19
|
+
- **Output transforms** -- Pipe text through built-in transforms (Pig Latin, leet speak, pirate, and more)
|
|
20
|
+
- **Traceable** -- Debug mode shows exactly how text was generated
|
|
21
|
+
- **Full CLI** -- Generate text, apply transforms, and validate lexicons from the command line
|
|
22
|
+
- **Zero dependencies** -- Works standalone or with @faker-js/faker
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
npm install marlarky
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Source Code & Issues
|
|
31
|
+
|
|
32
|
+
**Source**: https://github.com/JPaulDuncan/marlarky
|
|
33
|
+
|
|
34
|
+
**Issues**: https://github.com/JPaulDuncan/marlarky/issues
|
|
35
|
+
|
|
36
|
+
**Additional Usage**: https://jpaulduncan.github.io/marlarky/usage.md
|
|
37
|
+
|
|
38
|
+
**License**: MIT
|
|
39
|
+
|
|
40
|
+
## Quick Start
|
|
41
|
+
|
|
42
|
+
### TypeScript / JavaScript
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
import { TextGenerator, SimpleFakerAdapter } from 'marlarky';
|
|
46
|
+
|
|
47
|
+
const generator = new TextGenerator({
|
|
48
|
+
fakerAdapter: new SimpleFakerAdapter(),
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
generator.setSeed(42);
|
|
52
|
+
|
|
53
|
+
console.log(generator.sentence());
|
|
54
|
+
// "Generally, the change called."
|
|
55
|
+
|
|
56
|
+
console.log(generator.paragraph({ sentences: 3 }));
|
|
57
|
+
// Three sentences of plausible nonsense
|
|
58
|
+
|
|
59
|
+
console.log(generator.textBlock({ paragraphs: 2 }));
|
|
60
|
+
// Two paragraphs of corporate-sounding marlarky
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Command Line
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Generate a sentence
|
|
67
|
+
marlarky sentence
|
|
68
|
+
|
|
69
|
+
# Generate a deterministic question
|
|
70
|
+
marlarky sentence --seed 42 --type question
|
|
71
|
+
|
|
72
|
+
# Generate a paragraph with a corporate lexicon
|
|
73
|
+
marlarky paragraph --sentences 5 --lexicon ./corp.json --archetype corporate
|
|
74
|
+
|
|
75
|
+
# Apply Pig Latin transform and output as JSON
|
|
76
|
+
marlarky sentence --seed 42 --transform pigLatin --json
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## CLI
|
|
80
|
+
|
|
81
|
+
After installing globally (`npm install -g marlarky`) or locally, the `marlarky` command is available.
|
|
82
|
+
|
|
83
|
+
### Commands
|
|
84
|
+
|
|
85
|
+
| Command | Description |
|
|
86
|
+
| ----------- | ------------------------------------------- |
|
|
87
|
+
| `sentence` | Generate one or more sentences |
|
|
88
|
+
| `paragraph` | Generate one or more paragraphs |
|
|
89
|
+
| `text` | Generate a text block (multiple paragraphs) |
|
|
90
|
+
| `validate` | Validate a lexicon JSON file |
|
|
91
|
+
| `list` | List available transforms or sentence types |
|
|
92
|
+
|
|
93
|
+
### Global Options
|
|
94
|
+
|
|
95
|
+
These options work with `sentence`, `paragraph`, and `text`:
|
|
96
|
+
|
|
97
|
+
| Option | Short | Description |
|
|
98
|
+
| -------------------- | ----- | ------------------------------------------------------- |
|
|
99
|
+
| `--seed <n>` | `-s` | RNG seed for deterministic output |
|
|
100
|
+
| `--lexicon <path>` | `-l` | Path to a lexicon JSON file |
|
|
101
|
+
| `--archetype <name>` | `-a` | Archetype to activate from the lexicon |
|
|
102
|
+
| `--transform <id>` | `-x` | Apply an output transform (repeatable, comma-separated) |
|
|
103
|
+
| `--trace` | `-t` | Output JSON trace to stderr |
|
|
104
|
+
| `--json` | `-j` | Output full result as JSON to stdout |
|
|
105
|
+
| `--count <n>` | `-n` | Number of items to generate (default: 1) |
|
|
106
|
+
| `--help` | `-h` | Show help |
|
|
107
|
+
| `--version` | `-v` | Show version |
|
|
108
|
+
|
|
109
|
+
### Generating Sentences
|
|
110
|
+
|
|
111
|
+
```bash
|
|
112
|
+
# Random sentence
|
|
113
|
+
marlarky sentence
|
|
114
|
+
|
|
115
|
+
# Specific type
|
|
116
|
+
marlarky sentence --type question
|
|
117
|
+
marlarky sentence --type compound
|
|
118
|
+
marlarky sentence --type subordinate
|
|
119
|
+
|
|
120
|
+
# Control word count
|
|
121
|
+
marlarky sentence --min-words 10 --max-words 20
|
|
122
|
+
|
|
123
|
+
# Multiple sentences
|
|
124
|
+
marlarky sentence --count 5
|
|
125
|
+
|
|
126
|
+
# With hints (activate lexicon tags)
|
|
127
|
+
marlarky sentence --hints domain:tech,register:formal
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Generating Paragraphs
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Random paragraph
|
|
134
|
+
marlarky paragraph
|
|
135
|
+
|
|
136
|
+
# Control sentence count
|
|
137
|
+
marlarky paragraph --sentences 5
|
|
138
|
+
marlarky paragraph --min-sentences 3 --max-sentences 8
|
|
139
|
+
|
|
140
|
+
# Multiple paragraphs
|
|
141
|
+
marlarky paragraph --count 3
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
### Generating Text Blocks
|
|
145
|
+
|
|
146
|
+
```bash
|
|
147
|
+
# Random text block
|
|
148
|
+
marlarky text
|
|
149
|
+
|
|
150
|
+
# Control paragraph count
|
|
151
|
+
marlarky text --paragraphs 4
|
|
152
|
+
marlarky text --min-paragraphs 2 --max-paragraphs 6
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Applying Transforms
|
|
156
|
+
|
|
157
|
+
Use `--transform` (or `-x`) to pipe generated text through built-in transforms:
|
|
158
|
+
|
|
159
|
+
```bash
|
|
160
|
+
# Pig Latin
|
|
161
|
+
marlarky sentence --seed 42 --transform pigLatin
|
|
162
|
+
# "Enerallygay, ethay angechay alledcay."
|
|
163
|
+
|
|
164
|
+
# Leet speak
|
|
165
|
+
marlarky sentence --seed 42 --transform leet
|
|
166
|
+
|
|
167
|
+
# Chain multiple transforms (comma-separated)
|
|
168
|
+
marlarky sentence --seed 42 --transform leet,uwu
|
|
169
|
+
|
|
170
|
+
# Or use repeated flags
|
|
171
|
+
marlarky sentence --seed 42 -x pirate -x mockCase
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
Run `marlarky list transforms` to see all available transforms.
|
|
175
|
+
|
|
176
|
+
### JSON Output
|
|
177
|
+
|
|
178
|
+
Use `--json` (or `-j`) to get structured output including metadata and trace:
|
|
179
|
+
|
|
180
|
+
```bash
|
|
181
|
+
marlarky sentence --seed 42 --json
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
```json
|
|
185
|
+
{
|
|
186
|
+
"text": "Generally, the change called.",
|
|
187
|
+
"trace": { "...": "..." },
|
|
188
|
+
"meta": {
|
|
189
|
+
"archetype": "default",
|
|
190
|
+
"seed": 42
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
### Validating Lexicons
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Human-readable output
|
|
199
|
+
marlarky validate ./my-lexicon.json
|
|
200
|
+
|
|
201
|
+
# Machine-readable JSON output
|
|
202
|
+
marlarky validate ./my-lexicon.json --json
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Listing Available Features
|
|
206
|
+
|
|
207
|
+
```bash
|
|
208
|
+
# List all output transforms
|
|
209
|
+
marlarky list transforms
|
|
210
|
+
|
|
211
|
+
# List all sentence types
|
|
212
|
+
marlarky list types
|
|
213
|
+
|
|
214
|
+
# Output as JSON
|
|
215
|
+
marlarky list transforms --json
|
|
216
|
+
```
|
|
217
|
+
|
|
218
|
+
## Output Transforms
|
|
219
|
+
|
|
220
|
+
Marlarky includes 10 built-in output transforms that modify generated text at the token level. All transforms are deterministic (same seed = same output) and safe to chain.
|
|
221
|
+
|
|
222
|
+
| Transform | Description |
|
|
223
|
+
| -------------- | ------------------------------------- |
|
|
224
|
+
| `pigLatin` | Classic Pig Latin |
|
|
225
|
+
| `ubbiDubbi` | Ubbi Dubbi language game |
|
|
226
|
+
| `leet` | Leetspeak character substitution |
|
|
227
|
+
| `uwu` | Cute speak (w-substitution, suffixes) |
|
|
228
|
+
| `pirate` | Pirate speak |
|
|
229
|
+
| `redact` | Redact/mask words |
|
|
230
|
+
| `emoji` | Add emoji replacements |
|
|
231
|
+
| `mockCase` | rAnDoM cAsE aLtErNaTiOn |
|
|
232
|
+
| `reverseWords` | Reverse word order |
|
|
233
|
+
| `bizJargon` | Business jargon patterns |
|
|
234
|
+
|
|
235
|
+
### Using Transforms in Code
|
|
236
|
+
|
|
237
|
+
```typescript
|
|
238
|
+
const result = generator.sentence({
|
|
239
|
+
outputTransforms: {
|
|
240
|
+
enabled: true,
|
|
241
|
+
pipeline: [{ id: 'pigLatin' }],
|
|
242
|
+
},
|
|
243
|
+
});
|
|
244
|
+
```
|
|
245
|
+
|
|
246
|
+
Transforms can also be configured at the lexicon level or per-archetype in your lexicon JSON. See the [usage guide](https://jpaulduncan.github.io/marlarky/usage.md) for details.
|
|
247
|
+
|
|
248
|
+
## Sentence Types
|
|
249
|
+
|
|
250
|
+
Marlarky generates six sentence structures:
|
|
251
|
+
|
|
252
|
+
```typescript
|
|
253
|
+
// Simple declarative: "The system processes data."
|
|
254
|
+
generator.sentence({ type: 'simpleDeclarative' });
|
|
255
|
+
|
|
256
|
+
// Question: "Does the team deliver results?"
|
|
257
|
+
generator.sentence({ type: 'question' });
|
|
258
|
+
|
|
259
|
+
// Compound: "The strategy evolved, and the metrics improved."
|
|
260
|
+
generator.sentence({ type: 'compound' });
|
|
261
|
+
|
|
262
|
+
// Subordinate clause: "Because the pipeline scales, the throughput increases."
|
|
263
|
+
generator.sentence({ type: 'subordinate' });
|
|
264
|
+
|
|
265
|
+
// Intro adverbial: "Furthermore, the initiative drives innovation."
|
|
266
|
+
generator.sentence({ type: 'introAdverbial' });
|
|
267
|
+
|
|
268
|
+
// Interjection: "Indeed, the team delivered results."
|
|
269
|
+
generator.sentence({ type: 'interjection' });
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
## Deterministic Output
|
|
273
|
+
|
|
274
|
+
Same seed produces the same text every time:
|
|
275
|
+
|
|
276
|
+
```typescript
|
|
277
|
+
generator.setSeed(12345);
|
|
278
|
+
const a = generator.sentence();
|
|
279
|
+
|
|
280
|
+
generator.setSeed(12345);
|
|
281
|
+
const b = generator.sentence();
|
|
282
|
+
|
|
283
|
+
console.log(a === b); // true
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
From the CLI:
|
|
287
|
+
|
|
288
|
+
```bash
|
|
289
|
+
marlarky sentence --seed 12345
|
|
290
|
+
marlarky sentence --seed 12345
|
|
291
|
+
# Both print the same sentence
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## Custom Lexicons
|
|
295
|
+
|
|
296
|
+
Create domain-specific marlarky with JSON lexicon files:
|
|
297
|
+
|
|
298
|
+
```json
|
|
299
|
+
{
|
|
300
|
+
"id": "lexicon.startup",
|
|
301
|
+
"language": "en",
|
|
302
|
+
"termSets": {
|
|
303
|
+
"noun.startup": {
|
|
304
|
+
"pos": "noun",
|
|
305
|
+
"tags": ["domain:startup"],
|
|
306
|
+
"terms": [
|
|
307
|
+
{ "value": "disruptor", "weight": 5 },
|
|
308
|
+
{ "value": "unicorn", "weight": 3 },
|
|
309
|
+
{ "value": "pivot", "weight": 4 },
|
|
310
|
+
{ "value": "runway", "weight": 2 }
|
|
311
|
+
]
|
|
312
|
+
},
|
|
313
|
+
"verb.startup": {
|
|
314
|
+
"pos": "verb",
|
|
315
|
+
"tags": ["domain:startup"],
|
|
316
|
+
"terms": [
|
|
317
|
+
{ "value": "disrupt", "weight": 5 },
|
|
318
|
+
{ "value": "scale", "weight": 4 },
|
|
319
|
+
{ "value": "pivot", "weight": 3 },
|
|
320
|
+
{ "value": "iterate", "weight": 3 }
|
|
321
|
+
]
|
|
322
|
+
}
|
|
323
|
+
},
|
|
324
|
+
"archetypes": {
|
|
325
|
+
"startup": {
|
|
326
|
+
"tags": ["domain:startup"]
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
```
|
|
331
|
+
|
|
332
|
+
Load it in code:
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
import {
|
|
336
|
+
TextGenerator,
|
|
337
|
+
SimpleFakerAdapter,
|
|
338
|
+
loadLexiconFromString,
|
|
339
|
+
} from 'marlarky';
|
|
340
|
+
import { readFileSync } from 'fs';
|
|
341
|
+
|
|
342
|
+
const lexicon = loadLexiconFromString(readFileSync('./startup.json', 'utf-8'));
|
|
343
|
+
|
|
344
|
+
const generator = new TextGenerator({
|
|
345
|
+
fakerAdapter: new SimpleFakerAdapter(),
|
|
346
|
+
lexicon,
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
generator.setArchetype('startup');
|
|
350
|
+
console.log(generator.paragraph());
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
Or from the CLI:
|
|
354
|
+
|
|
355
|
+
```bash
|
|
356
|
+
marlarky paragraph --lexicon ./startup.json --archetype startup
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
See the [usage guide](usage.md#lexicon-schema) for the full lexicon schema reference.
|
|
360
|
+
|
|
361
|
+
## Morphology Utilities
|
|
362
|
+
|
|
363
|
+
Marlarky exports standalone English morphology functions:
|
|
364
|
+
|
|
365
|
+
```typescript
|
|
366
|
+
import {
|
|
367
|
+
pluralize,
|
|
368
|
+
singularize,
|
|
369
|
+
getPastTense,
|
|
370
|
+
getPresentParticiple,
|
|
371
|
+
getThirdPersonSingular,
|
|
372
|
+
getIndefiniteArticle,
|
|
373
|
+
} from 'marlarky';
|
|
374
|
+
|
|
375
|
+
pluralize('synergy'); // "synergies"
|
|
376
|
+
pluralize('child'); // "children"
|
|
377
|
+
singularize('stakeholders'); // "stakeholder"
|
|
378
|
+
getPastTense('leverage'); // "leveraged"
|
|
379
|
+
getPastTense('go'); // "went"
|
|
380
|
+
getPresentParticiple('run'); // "running"
|
|
381
|
+
getThirdPersonSingular('do'); // "does"
|
|
382
|
+
getIndefiniteArticle('hour'); // "an"
|
|
383
|
+
getIndefiniteArticle('user'); // "a"
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
## With @faker-js/faker
|
|
387
|
+
|
|
388
|
+
For more word variety, use the optional faker-js adapter:
|
|
389
|
+
|
|
390
|
+
```typescript
|
|
391
|
+
import { TextGenerator, FakerJsAdapter } from 'marlarky';
|
|
392
|
+
import { faker } from '@faker-js/faker';
|
|
393
|
+
|
|
394
|
+
const generator = new TextGenerator({
|
|
395
|
+
fakerAdapter: new FakerJsAdapter(faker),
|
|
396
|
+
});
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
`@faker-js/faker` is an optional peer dependency -- Marlarky works without it using the built-in `SimpleFakerAdapter`.
|
|
400
|
+
|
|
401
|
+
## Configuration
|
|
402
|
+
|
|
403
|
+
Fine-tune generation behavior:
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
const generator = new TextGenerator({
|
|
407
|
+
fakerAdapter: new SimpleFakerAdapter(),
|
|
408
|
+
config: {
|
|
409
|
+
minWordsPerSentence: 10,
|
|
410
|
+
maxWordsPerSentence: 25,
|
|
411
|
+
minSentencesPerParagraph: 3,
|
|
412
|
+
maxSentencesPerParagraph: 6,
|
|
413
|
+
questionRate: 0.05,
|
|
414
|
+
compoundRate: 0.2,
|
|
415
|
+
subordinateClauseRate: 0.15,
|
|
416
|
+
maxPPChain: 2,
|
|
417
|
+
maxAdjectivesPerNoun: 2,
|
|
418
|
+
},
|
|
419
|
+
});
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
See the [usage guide](usage.md#configuration) for all configuration options.
|
|
423
|
+
|
|
424
|
+
## Tracing
|
|
425
|
+
|
|
426
|
+
Enable trace mode to see how text was generated:
|
|
427
|
+
|
|
428
|
+
```typescript
|
|
429
|
+
const generator = new TextGenerator({
|
|
430
|
+
fakerAdapter: new SimpleFakerAdapter(),
|
|
431
|
+
enableTrace: true,
|
|
432
|
+
});
|
|
433
|
+
|
|
434
|
+
const result = generator.sentence();
|
|
435
|
+
|
|
436
|
+
console.log(result.text);
|
|
437
|
+
// "The robust system efficiently processes data."
|
|
438
|
+
|
|
439
|
+
console.log(result.trace.paragraphs[0].sentences[0].template);
|
|
440
|
+
// "simpleDeclarative"
|
|
441
|
+
|
|
442
|
+
console.log(result.trace.paragraphs[0].sentences[0].tokens);
|
|
443
|
+
// [{ value: "The", source: "default" }, { value: "robust", source: "adj.business" }, ...]
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
From the CLI, use `--trace` to send trace data to stderr, or `--json` to include it in structured stdout output.
|
|
447
|
+
|
|
448
|
+
## Examples
|
|
449
|
+
|
|
450
|
+
```bash
|
|
451
|
+
# Run the basic usage example
|
|
452
|
+
npm run example:basic
|
|
453
|
+
|
|
454
|
+
# Run the corporate lexicon example
|
|
455
|
+
npm run example:corporate
|
|
456
|
+
```
|
|
457
|
+
|
|
458
|
+
## Development
|
|
459
|
+
|
|
460
|
+
```bash
|
|
461
|
+
# Install dependencies
|
|
462
|
+
npm install
|
|
463
|
+
|
|
464
|
+
# Build
|
|
465
|
+
npm run build
|
|
466
|
+
|
|
467
|
+
# Run tests (watch mode)
|
|
468
|
+
npm test
|
|
469
|
+
|
|
470
|
+
# Run tests once
|
|
471
|
+
npm run test:run
|
|
472
|
+
|
|
473
|
+
# Run tests with coverage
|
|
474
|
+
npm run test:coverage
|
|
475
|
+
|
|
476
|
+
# Lint
|
|
477
|
+
npm run lint
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
## API Summary
|
|
481
|
+
|
|
482
|
+
For the complete API reference including all types, interfaces, and configuration options, see the [usage guide](usage.md).
|
|
483
|
+
|
|
484
|
+
| Method / Function | Description |
|
|
485
|
+
| ------------------------------ | ------------------------------------ |
|
|
486
|
+
| `new TextGenerator(opts)` | Create a generator instance |
|
|
487
|
+
| `generator.sentence(opts?)` | Generate one sentence |
|
|
488
|
+
| `generator.paragraph(opts?)` | Generate a paragraph (2-7 sentences) |
|
|
489
|
+
| `generator.textBlock(opts?)` | Generate multiple paragraphs |
|
|
490
|
+
| `generator.setSeed(n)` | Set RNG seed for reproducibility |
|
|
491
|
+
| `generator.setLexicon(lex)` | Load or replace a lexicon at runtime |
|
|
492
|
+
| `generator.setArchetype(name)` | Activate a style preset |
|
|
493
|
+
| `validateLexicon(obj)` | Validate a lexicon object |
|
|
494
|
+
| `loadLexiconFromString(json)` | Parse a lexicon JSON string |
|
|
495
|
+
|
|
496
|
+
## License
|
|
497
|
+
|
|
498
|
+
MIT
|
|
499
|
+
|
|
500
|
+
---
|
|
501
|
+
|
|
502
|
+
_"Leveraging synergistic paradigms to facilitate robust deliverables across the ecosystem."_
|
|
503
|
+
-- marlarky
|