rita 3.0.23 → 3.0.26

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/rita.cjs CHANGED
@@ -41933,8 +41933,8 @@ var _RiMarkov = class _RiMarkov {
41933
41933
  * @param {boolean} [options.trace] - output trace info to the console
41934
41934
  * @param {number} [options.maxLengthMatch] - # of words allowed in result to match a sequence in the input, default=∞
41935
41935
  * @param {number} [options.maxAttempts=999] - max attempts before to complete one ore more generations before erroring, default=999
41936
- * @param {function} [options.tokenize] - custom tokenizer with tokenize() method, defaults to RiTa.tokenize()
41937
- * @param {function} [options.untokenize] - custom untokenizer with untokenize() method, defaults to RiTa.untokenize()
41936
+ * @param {object} [options.tokenize] - custom tokenize() function, defaults to RiTa.tokenize()
41937
+ * @param {function} [options.untokenize] - custom untokenize() function, defaults to RiTa.untokenize()
41938
41938
  * @param {boolean} [options.disableInputChecks=false] - if true, allow result to be present in the input, default
41939
41939
  * @memberof RiMarkov
41940
41940
  */
@@ -41967,7 +41967,7 @@ var _RiMarkov = class _RiMarkov {
41967
41967
  */
41968
41968
  addText(text, multiplier = 1) {
41969
41969
  let sents = Array.isArray(text) ? text : _RiMarkov.parent.sentences(text);
41970
- let wrap, allWords = [];
41970
+ let allWords = [];
41971
41971
  for (let k = 0; k < multiplier; k++) {
41972
41972
  for (let i = 0; i < sents.length; i++) {
41973
41973
  let words = this.tokenize(sents[i]);
@@ -41984,19 +41984,34 @@ var _RiMarkov = class _RiMarkov {
41984
41984
  }
41985
41985
  return this;
41986
41986
  }
41987
- /**
41988
- * Generates `count` joined sentences from the model.
41989
- * @param {number} [count=1] - the number of sentences to generate (default=1)
41987
+ /**
41988
+ * @overload
41989
+ * @param {number} count
41990
41990
  * @param {object} [options={}] - options for the generation
41991
41991
  * @param {number} [options.minLength=5] - minimum length of each sentence
41992
41992
  * @param {number} [options.maxLength=35] - maximum length of each sentence
41993
41993
  * @param {number} [options.temperature=1] - temperature acts as a knob to adjust the probability that input elements will be selected for the output. At higher values, infrequent words are more likely to be chosen, while at lower values the most frequent inputs are more likely to be output. If no value is provided, then tokens are chosen according to their relative frequency in the input.
41994
41994
  * @param {boolean} [options.allowDuplicates=false] - if true, allow duplicate sentences in the output
41995
41995
  * @param {string|string[]} [options.seed] - a seed string or array of tokens to start the generation
41996
- * @param {boolean} [options.trace] - output trace info to the console
41997
- * @return {string[]} - the generated sentences
41996
+ * @returns {string[]}
41997
+ *
41998
+ * @overload
41999
+ * @param {object} [options={}] - options for the generation
42000
+ * @param {number} [options.minLength=5] - minimum length of each sentence
42001
+ * @param {number} [options.maxLength=35] - maximum length of each sentence
42002
+ * @param {number} [options.temperature=1] - temperature acts as a knob to adjust the probability that input elements will be selected for the output. At higher values, infrequent words are more likely to be chosen, while at lower values the most frequent inputs are more likely to be output. If no value is provided, then tokens are chosen according to their relative frequency in the input.
42003
+ * @param {boolean} [options.allowDuplicates=false] - if true, allow duplicate sentences in the output
42004
+ * @param {string|string[]} [options.seed] - a seed string or array of tokens to start the generation
42005
+ * @returns {string}
41998
42006
  */
41999
42007
  generate(count, options = {}) {
42008
+ let returnsArray = false;
42009
+ if (typeof count === "number") {
42010
+ if (count === 1) {
42011
+ throw Error("For one result, use generate() with no 'count' argument");
42012
+ }
42013
+ returnsArray = true;
42014
+ }
42000
42015
  if (arguments.length === 1 && typeof count === "object") {
42001
42016
  options = count;
42002
42017
  count = 1;
@@ -42182,7 +42197,7 @@ var _RiMarkov = class _RiMarkov {
42182
42197
  }
42183
42198
  unmarkNodes();
42184
42199
  let str = this.untokenize(tokens.map((t) => t.token)).trim();
42185
- return num > 1 ? this._splitEnds(str) : str;
42200
+ return returnsArray ? this._splitEnds(str) : str;
42186
42201
  }
42187
42202
  /**
42188
42203
  * Converts the model to a JSON-formatted string for storage or serialization
@@ -43221,7 +43236,7 @@ markov_default.parent = RiTa;
43221
43236
  stemmer_default.tokenizer = RiTa.tokenizer;
43222
43237
  RiTa.SILENT = false;
43223
43238
  RiTa.SILENCE_LTS = false;
43224
- RiTa.VERSION = "3.0.23";
43239
+ RiTa.VERSION = "3.0.26";
43225
43240
  RiTa.FIRST = 1;
43226
43241
  RiTa.SECOND = 2;
43227
43242
  RiTa.THIRD = 3;