generate random poetry using linguistics!
good ol' npm install
followed by npm run dev
will give you a nice local
server. build with npm run build
. both of these commands run
npm run build:emoji
and then a vite
command.
build:emoji
generates the src/emojiData.json
file, which is used by the
website.
everything flows pretty much sequentially:
-
src.generateEmoji.ts
uses thecmudict
andunicode
packages to get linguistic properties for a list of emoji characters. these packages bundle a lot of data so in order to avoid fetching them on the front end this file generatessrc/emojiData.json
(vianpm run build:emoji
). -
src/emoji.ts
provides a nice wrapper around the data insrc/emojiData.json
-
src/sequence.ts
exposes a couple of things. the most important one is thematch
function, which takes in a scansion (a sequence of/
andx
characters and randomly picks emoji to fit that pattern). the other exports (matchWithConstrainedEnd
,isEmojiValidAsEnding
, andisSequenceValidAsEnding
) are related to rhyming. all of these functions are used insrc/template.ts
. -
src/template.ts
is in charge of generating an entire template, with many scansion sequences and raw text.parseTemplate
parses the template string and gives an array of atoms, andgenerate
takes that array and generates emoji sequences where necessary (usinggenerateAtom
). rhyming related things live in this file because they need more context that a single sequence. rhyming works by picking rhyming emoji to go at the ends of sequences with the same rhyme group (denoted using a letter in parentheses at the end of a sequence). -
src/useTemplate.ts
wraps the functions intemplate.ts
in a nice little react hook, to be used by the main component. -
src/App.tsx
is the main (and only) component. it triggers parsing and generation fromtemplate.ts
via theuseTemplate
hook.