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
npm install word-fabricator
Returns a function to make configurations for how the words will be fabricated
const configure_word_fabricator = require('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
This plain object may specify any rules, however it must specify the required rules; blueprint
, max_length
and initial_parts
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
This object may be undefined
to change nothing or specify new rules and/or change predefined initial rules
const list_of_words = words.join(', ');
console.log(list_of_words);
* Required in initial_rules
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: [],
}
The maximum number of letters word-fabricator will try to build words
max_length: 6,
An array of letter segments which every word will be built upon
initial_parts: ['dr', 'ago', 'n', 'e'],
- 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
- All rules are allowed as snake_case as well as camelCase (other cases?)
- Decide if standard should be max segments instead of max length
- install the package
- require the package
- provide some initial rules
- throws error if something is invalid
- run the function with some additional rules
- get the fabricated words