nimkov/typedefs

Source   Edit  

Types

MarkovEmptyModelError = object of MarkovError
  
Throws if trying to generate with empty model Source   Edit  
MarkovError = object of CatchableError
Source   Edit  
MarkovGenerateOptions = object of RootObj
  attempts*: Positive
  begin*: Option[string]
  validator*: MarkovValidator
Options for generator. Source   Edit  
MarkovGeneratorModelType = enum
  mgtSimple, mgtWeighted
Type of model, which will be used in generator. mgtSimple - simple model, which will be generated with equal probability, i.e. model will be Table[string, seq[string]] mgtWeighted - weighted model, which will be generated with weighted probability, i.e. model will be Table[string, Table[string, int]] Source   Edit  
MarkovNotEnoughSamplesError = object of MarkovError
  
Throws if not found last word of beginning in model Source   Edit  
MarkovOutOfAttemptsError = object of MarkovError
  
Throws if generating is out of attempts Source   Edit  
MarkovProcessWordProc = proc (word: string): Option[string]
Process word, result string will be added to model, if you don't want to add word to model - return none string. Recommended to lower case always, which is default Source   Edit  
MarkovValidator = proc (str: string): bool
Validator for generator. If generated text doesn't satisfy the validator - it will try to generate a new string, if the number of attempts allows. Source   Edit