@radically-straightforward/examples v1.0.0
Radically Straightforward · Examples
🥸 Example data for testing
Installation
$ npm install @radically-straightforward/examplesUsage
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.jsonwith a list of Wikipedia articles on subjects that themodelshould 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/examplesto collect those Wikipedia articles:$ npx examples collectA file called
corpus.jsonis created with the collected Wikipedia articles, and theurls.jsonfile 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
modelwith the binary that comes with@radically-straightforward/examples:$ npx examples trainThis produces a file called
model.jsonwhich includes the model, and its contents can be provided totext()as themodel.At this point you may delete the files
urls.jsonandcorpus.jsonif 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.
2 years ago