Created
March 9, 2023 14:39
-
-
Save ajkachnic/e41d4dbb0c626e90f591036e1761dc51 to your computer and use it in GitHub Desktop.
Jargonator
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', | |
'fungible', | |
'synergize' | |
] | |
const nouns = [ | |
'leverage', | |
'crypto', | |
'NFT', | |
'blockchain', | |
'10x engineer', | |
'fintech', | |
'artifical intelligence', | |
'encryption', | |
'end-to-end encryption', | |
'deep learning', | |
'algorithm', | |
'~~bugs~~features', | |
'startup', | |
'cloud', | |
'market', | |
'AI', | |
'GPT3', | |
'fiat', | |
'Kubernetes', | |
] | |
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)() | |
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(8)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment