Giter VIP home page Giter VIP logo

word-fabricator's Introduction

Word Fabricator

Generate fictional words by specifying rules


const configure_word_fabricator = require('./path/to/word-fabricator');

const word_fabricator = configure_word_fabricator({
    blueprint: {
        dr: ['ago', 'e'],
        ago: ['n'],
        n: ['e', 'ago'],
        e: ['gg'],
        gg: [],
    },
    max_length: 6,
    initial_parts: ['dr', 'ago', 'n', 'e'],
});

const fictional_words = word_fabricator();

console.log(fictional_words.join(', '));

// dr, drago, dragon, dre, dregg, ago, agon, agone, n, ne, negg, nago, nagon, nagone, e, egg

code from demo/usage.js



Getting started

How to install

npm install word-fabricator

How to use


require('word-fabricator')

Returns a function to make configurations for how the words will be fabricated

const configure_word_fabricator = require('word-fabricator');

configure_word_fabricator

This function requires some initial rules and returns the actual word_fabricator

const word_fabricator = configure_word_fabricator(initial_rules); // specify required rules

initial_rules

This plain object may specify any rules, however it must specify the required rules; blueprint, max_length and initial_parts


word_fabricator

Returns the array of fictional words which are fabricated using the provided rules (initial rules and additional rules)

const words = word_fabricator(); // change nothing
// or
const words = word_fabricator(additional_rules); // override/append rules

additional_rules

This object may be undefined to change nothing or specify new rules and/or change predefined initial rules


console.log the list of fabricated words

const list_of_words = words.join(', ');

console.log(list_of_words);


The rules

* Required in initial_rules

blueprint*

An object where the values is an array of different letters, or rather segments, which are allowed to succeed after the letter segment which is its key. Segments are either one or multiple letters in a string

blueprint: {
    dr: ['ago', 'e'],
    ago: ['n'],
    n: ['e', 'ago'],
    e: ['gg'],
    gg: [],
}

max_length*

The maximum number of letters word-fabricator will try to build words

max_length: 6,

initial_parts*

An array of letter segments which every word will be built upon

initial_parts: ['dr', 'ago', 'n', 'e'],

Roadmap

  • Validate rules
  • Provide great error messages
  • Arrays and strings should kind of be seen as the same
  • Add some more rules
    • min_length
    • length (specified exact length)
    • Words to be excluded
      • Exact match
      • Substring
      • Regex
    • Something about the endings of the words (allowed, disallowed)
    • Limit the amount of words to be fabricated at a time

Maybe

  • All rules are allowed as snake_case as well as camelCase (other cases?)
  • Decide if standard should be max segments instead of max length

The user experience I would like to achieve

  1. install the package
  2. require the package
  3. provide some initial rules
    1. throws error if something is invalid
  4. run the function with some additional rules
  5. get the fabricated words

word-fabricator's People

Contributors

davlin0222 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.