Created
August 15, 2021 02:41
-
-
Save ajkachnic/9fe79157d82c1a2aa00cb03ceb582a63 to your computer and use it in GitHub Desktop.
Jargon generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const verbs = [ | |
'circle back', | |
'hustle', | |
'pivot', | |
'disrupt', | |
'sync up', | |
'leverage', | |
'take a deep dive' | |
] | |
const adjectives = [ | |
'open-source', | |
'foss', | |
'agile', | |
'unicorn', | |
'disruptive', | |
'next gen' | |
] | |
const nouns = [ | |
'leverage', | |
'crypto', | |
'NFT', | |
'blockchain', | |
'10x engineer', | |
'fintech', | |
'artifical intelligence', | |
'encryption', | |
'end-to-end encryption', | |
'deep learning', | |
'algorithm', | |
'~~bugs~~features', | |
'startup', | |
'cloud', | |
'market' | |
] | |
const choose = arr => () => arr[Math.floor(Math.random() * arr.length)] | |
const chooseMany = arr => (num = 1, join = true) => { | |
// Remove duplicates by using an alternative algorithm | |
const temp = [...arr].sort((a, b) => Math.random() - 0.5) | |
const res = Array.from({ length: num }, () => temp.pop()) | |
return join ? res.join(' ') : res | |
} | |
const num = n => Math.floor(Math.random() * n) + 1 | |
const bool = () => Math.random() > 0.5 | |
const match = (term, cases) => { | |
for (const [condition, value] of Object.entries(cases)) { | |
if (term == condition) return value | |
} | |
return cases['_'] | |
} | |
// VERY VERY SIMPLE ALGORITHM | |
const ing = (phrase) => { | |
const words = phrase.split(' ') | |
let word = words[0] | |
if (word.endsWith('e')) { | |
word = word.slice(0, -1) | |
} | |
word += 'ing' | |
return [word, ...words.slice(1)].join(' ') | |
} | |
const group = (verb, adj, noun) => { | |
const group = match(verb, { | |
'circle back': 'to', | |
'hustle': 'on', | |
'pivot': 'to', | |
'sync up': 'with', | |
'take a deep dive': 'into', | |
_: '' | |
}) | |
const next = match(noun, { | |
'cloud': 'the', | |
'algorithm': 'our', | |
'NFT': 'the', | |
_: '' | |
}) | |
return [verb, group, next, adj, noun].filter(a => a != '').join(' ') | |
} | |
const phrases = [ | |
({ noun, adj, verb }) => `We need to ${group(verb(), adj(), noun())}`, | |
({ noun, adj, verb }) => `Our team should ${group(verb(), adj(), noun())}`, | |
({ noun, adj, verb }) => `Our competitors have a better ${noun()}, but we bring our ${adj()} ${noun()} ${bool() ? `and our ${adj(3)} ${noun()} ` : ''}to the table`, | |
({ noun, adj, verb }) => `The ${adj()} approach that we choose allows us to ${group(verb(), adj(2), noun())}`, | |
({ noun, adj, verb }) => `I think we should ${group(verb(), '', noun())} and ${group(verb(), '', noun())} so we can move forward`, | |
({ noun, adj, verb }) => `This situation calls for the use of ${adj()} ${ing(verb())}`, | |
({ noun, adj, verb }) => `Their ${adj()} ${noun()} is performing better than our ${adj(2)} ${noun()}, so we need to ${verb()} and ${verb()}`, | |
({ noun, adj, verb }) => `The ${noun()} of our ${noun()} lets us ${group(verb(), adj(), noun())}` | |
] | |
const generate = () => { | |
const adj = chooseMany(adjectives) | |
const verb = chooseMany(verbs) | |
const noun = chooseMany(nouns) | |
const phrase = choose(phrases)() | |
console.log(phrase, typeof phrase) | |
return phrase({ adj, verb, noun }) | |
} | |
const generateMany = (num = 1) => { | |
const adj = chooseMany(adjectives) | |
const verb = chooseMany(verbs) | |
const noun = chooseMany(nouns) | |
const phrase = chooseMany(phrases)(num, false) | |
return phrase.map(phrase => phrase({ adj, verb, noun })).join('. ') | |
} | |
console.log(generateMany(4)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment