@radically-straightforward/examples
v1.0.0
Published
🥸 Example data for testing
Downloads
153
Maintainers
Readme
Radically Straightforward · Examples
🥸 Example data for testing
Installation
$ npm install @radically-straightforward/examples
Usage
import * as examples from "./index.mjs";
name()
export function name(): string;
Examples of names of people.
Sources
- First names: https://www.ssa.gov/oact/babynames/decades/century.html
- Last names: https://www.thoughtco.com/most-common-us-surnames-1422656
text()
export function text({
model = textModel,
length = 10,
}: {
model?: {
[predecessor: string]: {
[successor: string]: {
count: number;
percentile: number;
};
};
};
length?: number;
} = {}): string;
Example text.
If the length
is 0
, then the text is short and may not contain punctuation, which is suitable, for example, for the title of a conversation.
The default model
mostly talks about food. You may train your own model
on other subjects by following these steps:
Create a file called
urls.json
with a list of Wikipedia articles on subjects that themodel
should talk about, for example:urls.json
[ "https://en.wikipedia.org/wiki/Maple_syrup", "https://en.wikipedia.org/wiki/Chocolate_chip" ]
Run the binary that comes with
@radically-straightforward/examples
to collect those Wikipedia articles:$ npx examples collect
A file called
corpus.json
is created with the collected Wikipedia articles, and theurls.json
file is updated with more Wikipedia articles.Select the articles that you consider relevant in
urls.json
, return to step 1, and repeat until enough enough Wikipedia articles have been collected. A bigger corpus yields a richer model with more diverse example texts, but it also produces bigger files and risks going off-topic.Train the
model
with the binary that comes with@radically-straightforward/examples
:$ npx examples train
This produces a file called
model.json
which includes the model, and its contents can be provided totext()
as themodel
.At this point you may delete the files
urls.json
andcorpus.json
if you wish.
References
- https://healeycodes.com/generating-text-with-markov-chains
- https://www.youtube.com/watch?v=eGFJ8vugIWA
Avatars
The folder avatars/
contains 263 examples of faces.
These people don’t exist, the faces were collected from https://github.com/NVlabs/stylegan2 / https://drive.google.com/drive/folders/1mTeo3J3Jo6aYImBshLM6XRl_Ua8fqgVW and resized to 256×256px with avatars/index.mjs
.
Related Work
Faker, casual, and so forth
These other libraries don’t include text that can be trained on arbitrary topics and avatars.