Public
Edited
Dec 21, 2022
Insert cell
Insert cell
Insert cell
Insert cell
rawTexts = Promise.all([
FileAttachment("gen1.txt"),
FileAttachment("gen2.txt"),
FileAttachment("gen3.txt"),
FileAttachment("gen4.txt"),
FileAttachment("gen5.txt"),
FileAttachment("gen6.txt"),
FileAttachment("gen7.txt"),
FileAttachment("gen8.txt"),
FileAttachment("gen9.txt"),

].map(file => file.text()))
Insert cell
function parse(rawText) {
const matches = rawText.matchAll(
/\{\{pdex\|\d+\|([^|]+)\|\d+\|[^|]+\|[^|]*\|([^|]+)\|\/(.+)\/\}\}/g
);
return [...matches].map(extractMatchData);
}
Insert cell
allGens = rawTexts.map(parse)
Insert cell
allMons = allGens.flat()
Insert cell
function extractMatchData([match, name, pronunciation, ipa]) {
return { name, pronunciation, ipa }
}
Insert cell
// So apparently with soft rhymes you're supposed to include the consonant right before...
function getRhymeSyllable(word) {
// get the last vowel group and consonant cluster of a word
return word.match(/[ɪiʊuɛeəoæʌɑɔaɚɝː]+[^ɪiʊuɛeəoæʌɑɔaɚɝː]*$/)[0];
}
Insert cell
rhymeGroups = _.groupBy(allMons, mon => getRhymeSyllable(mon.ipa))
Insert cell
matchedRhymes = _.omitBy(rhymeGroups, group => group.length <= 1)
Insert cell
uniqueRhymes = _.filter(rhymeGroups, group => group.length <= 1).map(group => group[0])
Insert cell
function getMeter(pronunciation) {
return pronunciation.split('-').map(syllable => /[a-z]/.test(syllable) ? 'x' : '/')
}
Insert cell
// Mons that have two non-adjacent stressed syllables
allMons.filter((mon) => {
const meter = getMeter(mon.pronunciation);
return (
_.countBy(meter)["/"] > 1 &&
meter.lastIndexOf("/") - meter.indexOf("/") > 2
);
})
Insert cell
_ = require('lodash')
Insert cell
allMons.find(mon => mon.name === "Alomomola")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more