npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

gibberish-sentence-generator

v0.0.2

Published

Simple gibberish sentence generator

Downloads

3

Readme

gibberish-sentence-generator

Simply import the SentenceGenerator class, add syllable types and letter classes!

Letter classes are one-letter-named objects of letters and their corresponding weights.

For example, if you have two classes, named C and V (consonants and vowels respectively), they may look like this:

const classes = {
    C: {
        'b': 10,
        'c': 20,
        'd': 5,
        'g': 50
    },
    V: {
        'a': 2,
        'o': 1,
        'u': 3,
        'i': 0
    }
}

Here we can see that the letter g will be the most frequent consonant, 10 times as frequent as d and 5 times as frequent as b, for example.

In vowel department, u will be the most popular vowel, followed by a and then o. i will not be generated at all, since it has a weight of 0.

Syllable types are combinations of letter classes, they are also weighted.

To continue the above example, we will create two syllable types: open (consonant + vowel) and closed (consonant + vowel + consonant):

const syllableTypes = {
    CV: 100,
    CVC: 33
}

CV will be the most frequent syllable type (e.g. ba or du), while CVC (e.g. bad, guc) will be three times as rare.

In order to add your letter classes and syllable types, simply add them into the constructor parameter, like so:

const sg = new SentenceGenerator({
    classes: {
        C: {
            'b': 10,
            'c': 20,
            'd': 5,
            'g': 50
        },
        V: {
            'a': 2,
            'o': 1,
            'u': 3,
            'i': 0
        }
    },
    
    syllableTypes: {
        CV: 100,
        CVC: 33
    }
});

Then you can generate separate syllables, words and even sentences (as the package name implies):

console.log(sg.generateSyllable()) // prints "gub", CVC
console.log(sg.generateSyllable()) // prints "go", CV
console.log(sg.generateSyllable()) // prints "du", CV
console.log(sg.generateWord()) // prints "gagu", CV+CV
console.log(sg.generateWord()) // prints "cu", CV
console.log(sg.generateWord()) // prints "gugbucug", CVC+CV+CVC
console.log(sg.generateSentence()) // prints "Gogo cubgugo bugu, ca dubgu gucagu gaggugu ga gugog, gu bucuba co gobug, guc gagucgu"
console.log(sg.generateSentence()) // prints "Cacu gugogo dagbaggub coga gugo"
console.log(sg.generateSentence()) // prints "Gu gabuc gogu, guc gug gabugu"

Also, you can modify settings such as word length and sentence length:

const sg = new SentenceGenerator({
    wordOptions: {
        minSyllables: 5, // minimum random word length (in syllables)
        maxSyllables: 15 // maximum random word length (in syllables)
    },
    sentenceOptions: {
        minWords: 1, // minimum random sentence length (in words)
        maxWords: 15, // maximum random sentence length (in words)
        minWordsBeforeComma: 3, // minimum random amount of words after which to put comma
        maxWordsBeforeComma: 7 // maximum random amount of words after which to put comma
    },
    // put your classes and syllableTypes here
});