Generates a string with custom tokens and a minimum and a maximum number of random words picking from a dictionary.
- Source:
 
Methods
(static) generateTokenizedText(config, tokensopt, divideropt, minWordsopt, maxWordsopt, dictionaryopt) → {Object}
- Source:
 
Example
import { generateTokenizedText } from '@untemps/utils/string/generateTokenizedText'
const tokens = ['pol', 'biz', 'kuy']
const divider = '$'
const minWords = 5
const maxWords = 10
const dictionary = ['foo', 'bar', 'gag']
generateTokenizedText(tokens, divider, minWords, maxWords, dictionary) // {indices: Array(3), text: "foo $pol$ $biz$ bar gag $kuy$ foo gag foo"}}
    Parameters:
| Name | Type | Attributes | Default | Description | 
|---|---|---|---|---|
config | 
            
            object | The configuration object for the text generation.  | 
        ||
tokens | 
            
            Array.<string> | 
                
                    <optional> | 
            
            
                
                
                    []
                
                 | 
            
            The list of tokens.  | 
        
divider | 
            
            string | 
                
                    <optional> | 
            
            
                
                
                    '%'
                
                 | 
            
            The symbol that identifies a token.  | 
        
minWords | 
            
            number | 
                
                    <optional> | 
            
            
                
                
                    10
                
                 | 
            
            The minimum number of words to pick.  | 
        
maxWords | 
            
            number | 
                
                    <optional> | 
            
            
                
                
                    50
                
                 | 
            
            The maximum number of words to pick.  | 
        
dictionary | 
            
            Array.<string> | 
                
                    <optional> | 
            
            
                
                
                    [...]
                
                 | 
            
            A list of words from which picking the words.  | 
        
Returns:
An object containing a list of token indices and the generated string.
- Type
 - Object