rita 3.0.22 → 3.0.25
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 +245 -152
- package/dist/rita.cjs.map +1 -1
- package/dist/rita.d.ts +253 -0
- package/dist/rita.js +243 -150
- package/dist/rita.js.map +1 -1
- package/dist/rita.min.js +66 -66
- package/dist/rita.min.js.map +1 -1
- package/package.json +5 -6
package/dist/rita.js
CHANGED
|
@@ -845,32 +845,32 @@ var Tokenizer = class {
|
|
|
845
845
|
* Returns an array containing all unique alphabetical words (tokens) in the text.
|
|
846
846
|
* Punctuation and case are ignored unless specified otherwise.
|
|
847
847
|
* @param {string} text - The text from which to extract the tokens
|
|
848
|
-
* @param {object} [
|
|
849
|
-
* @param {boolean}
|
|
850
|
-
* @param {boolean}
|
|
851
|
-
* @param {boolean}
|
|
852
|
-
* @param {boolean}
|
|
853
|
-
* @param {boolean}
|
|
848
|
+
* @param {object} [options] - The options
|
|
849
|
+
* @param {boolean} [options.caseSensitive=false] - Whether to pay attention to case
|
|
850
|
+
* @param {boolean} [options.ignoreStopWords=false] - Whether to ignore words like 'the', 'and', 'a', 'of', etc, as specified in RiTa.STOP_WORDS
|
|
851
|
+
* @param {boolean} [options.splitContractions=false] - Whether to convert contractions (e.g., "I'd" or "she'll") into multiple individual tokens
|
|
852
|
+
* @param {boolean} [options.includePunct=false] - Whether to include punctuation in the results
|
|
853
|
+
* @param {boolean} [options.sort=false] - Whether to sort the tokens before returning them
|
|
854
854
|
* @returns {string[]} Array of tokens
|
|
855
855
|
*/
|
|
856
|
-
tokens(text,
|
|
856
|
+
tokens(text, options = {
|
|
857
857
|
caseSensitive: false,
|
|
858
858
|
ignoreStopWords: false,
|
|
859
859
|
splitContractions: false,
|
|
860
860
|
includePunct: false,
|
|
861
861
|
sort: false
|
|
862
862
|
}) {
|
|
863
|
-
let words = this.tokenize(text,
|
|
863
|
+
let words = this.tokenize(text, options), map = {};
|
|
864
864
|
words.forEach((w) => {
|
|
865
|
-
if (!
|
|
865
|
+
if (!options.caseSensitive)
|
|
866
866
|
w = w.toLowerCase();
|
|
867
|
-
if (
|
|
867
|
+
if (options.includePunct || ALPHA_RE.test(w))
|
|
868
868
|
map[w] = 1;
|
|
869
869
|
});
|
|
870
870
|
let tokens = Object.keys(map);
|
|
871
|
-
if (
|
|
871
|
+
if (options.ignoreStopWords)
|
|
872
872
|
tokens = tokens.filter((t) => !this.RiTa.isStopWord(t));
|
|
873
|
-
return
|
|
873
|
+
return options.sort ? tokens.sort() : tokens;
|
|
874
874
|
}
|
|
875
875
|
tokenize(input, opts = {
|
|
876
876
|
// regex: null,
|
|
@@ -41591,8 +41591,7 @@ var Analyzer = class {
|
|
|
41591
41591
|
return features;
|
|
41592
41592
|
}
|
|
41593
41593
|
computePhones(word, opts) {
|
|
41594
|
-
|
|
41595
|
-
this.lts = new rita_lts_default(this.RiTa);
|
|
41594
|
+
this.lts = this.lts || new rita_lts_default(this.RiTa);
|
|
41596
41595
|
return this.lts.buildPhones(word, opts);
|
|
41597
41596
|
}
|
|
41598
41597
|
phonesToStress(phones) {
|
|
@@ -41609,8 +41608,7 @@ var Analyzer = class {
|
|
|
41609
41608
|
return stress;
|
|
41610
41609
|
}
|
|
41611
41610
|
analyzeWord(word, opts = {}) {
|
|
41612
|
-
let
|
|
41613
|
-
let result = RiTa2.CACHING && this.cache[word];
|
|
41611
|
+
let result = this.RiTa.CACHING && this.cache[word];
|
|
41614
41612
|
if (typeof result === "undefined") {
|
|
41615
41613
|
let slash = "/", delim = "-";
|
|
41616
41614
|
let lex = this.RiTa.lexicon;
|
|
@@ -41639,7 +41637,7 @@ var Analyzer = class {
|
|
|
41639
41637
|
}
|
|
41640
41638
|
result = { phones, stresses, syllables };
|
|
41641
41639
|
Object.keys(result).forEach((k) => result[k] = result[k].trim());
|
|
41642
|
-
if (
|
|
41640
|
+
if (this.RiTa.CACHING)
|
|
41643
41641
|
this.cache[word] = result;
|
|
41644
41642
|
}
|
|
41645
41643
|
return result;
|
|
@@ -41926,15 +41924,29 @@ var randgen_default = SeededRandom;
|
|
|
41926
41924
|
import { parse, stringify } from "@ungap/structured-clone/json";
|
|
41927
41925
|
var _RiMarkov = class _RiMarkov {
|
|
41928
41926
|
// RiTa
|
|
41929
|
-
|
|
41927
|
+
/**
|
|
41928
|
+
* Creates a new RiMarkov object with functions for text-generation and other probabilistic functions,
|
|
41929
|
+
* via Markov chains (or n-grams) with options to process words or tokens split by arbitrary regular expressions.
|
|
41930
|
+
* @param {number} [n] - the n-gram size (an integer >= 2)
|
|
41931
|
+
* @param {object} [options={}] - options for the model
|
|
41932
|
+
* @param {string|string[]} [options.text] - a text string, or array of sentences, to add to the model (same as via model.addText()
|
|
41933
|
+
* @param {boolean} [options.trace] - output trace info to the console
|
|
41934
|
+
* @param {number} [options.maxLengthMatch] - # of words allowed in result to match a sequence in the input, default=∞
|
|
41935
|
+
* @param {number} [options.maxAttempts=999] - max attempts before to complete one ore more generations before erroring, default=999
|
|
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
|
+
* @param {boolean} [options.disableInputChecks=false] - if true, allow result to be present in the input, default
|
|
41939
|
+
* @memberof RiMarkov
|
|
41940
|
+
*/
|
|
41941
|
+
constructor(n, options = {}) {
|
|
41930
41942
|
this.n = n;
|
|
41931
41943
|
this.root = new Node(null, "ROOT");
|
|
41932
|
-
this.trace =
|
|
41933
|
-
this.mlm =
|
|
41934
|
-
this.maxAttempts =
|
|
41935
|
-
this.tokenize =
|
|
41936
|
-
this.untokenize =
|
|
41937
|
-
this.disableInputChecks =
|
|
41944
|
+
this.trace = options.trace;
|
|
41945
|
+
this.mlm = options.maxLengthMatch;
|
|
41946
|
+
this.maxAttempts = options.maxAttempts || 999;
|
|
41947
|
+
this.tokenize = options.tokenize || _RiMarkov.parent.tokenize;
|
|
41948
|
+
this.untokenize = options.untokenize || _RiMarkov.parent.untokenize;
|
|
41949
|
+
this.disableInputChecks = options.disableInputChecks;
|
|
41938
41950
|
this.sentenceStarts = [];
|
|
41939
41951
|
this.sentenceEnds = /* @__PURE__ */ new Set();
|
|
41940
41952
|
if (this.n < 2)
|
|
@@ -41943,12 +41955,19 @@ var _RiMarkov = class _RiMarkov {
|
|
|
41943
41955
|
throw Error("maxLengthMatch must be >= N");
|
|
41944
41956
|
if (!this.disableInputChecks || this.mlm)
|
|
41945
41957
|
this.input = [];
|
|
41946
|
-
if (
|
|
41947
|
-
this.addText(
|
|
41958
|
+
if (options.text)
|
|
41959
|
+
this.addText(options.text);
|
|
41948
41960
|
}
|
|
41961
|
+
/**
|
|
41962
|
+
* Loads text into the model. If a raw string is provided, it will be split into sentences
|
|
41963
|
+
* via RiTa.sentences(). If an array is provided, each string will be treated as an individual sentence.
|
|
41964
|
+
* @param {string|string[]} text - a text string, or array of sentences, to add to the model
|
|
41965
|
+
* @param {number} [multiplier=1] - number of times to add the text to the model
|
|
41966
|
+
* @return {RiMarkov} - the RiMarkov instance
|
|
41967
|
+
*/
|
|
41949
41968
|
addText(text, multiplier = 1) {
|
|
41950
41969
|
let sents = Array.isArray(text) ? text : _RiMarkov.parent.sentences(text);
|
|
41951
|
-
let
|
|
41970
|
+
let allWords = [];
|
|
41952
41971
|
for (let k = 0; k < multiplier; k++) {
|
|
41953
41972
|
for (let i = 0; i < sents.length; i++) {
|
|
41954
41973
|
let words = this.tokenize(sents[i]);
|
|
@@ -41963,19 +41982,47 @@ var _RiMarkov = class _RiMarkov {
|
|
|
41963
41982
|
this.input.push(allWords[i]);
|
|
41964
41983
|
}
|
|
41965
41984
|
}
|
|
41985
|
+
return this;
|
|
41966
41986
|
}
|
|
41967
|
-
|
|
41987
|
+
/**
|
|
41988
|
+
* @overload
|
|
41989
|
+
* @param {number} count
|
|
41990
|
+
* @param {object} [options={}] - options for the generation
|
|
41991
|
+
* @param {number} [options.minLength=5] - minimum length of each sentence
|
|
41992
|
+
* @param {number} [options.maxLength=35] - maximum length of each sentence
|
|
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
|
+
* @param {boolean} [options.allowDuplicates=false] - if true, allow duplicate sentences in the output
|
|
41995
|
+
* @param {string|string[]} [options.seed] - a seed string or array of tokens to start the generation
|
|
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}
|
|
42006
|
+
*/
|
|
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
|
+
}
|
|
41968
42015
|
if (arguments.length === 1 && typeof count === "object") {
|
|
41969
|
-
|
|
42016
|
+
options = count;
|
|
41970
42017
|
count = 1;
|
|
41971
42018
|
}
|
|
41972
42019
|
const num = count || 1;
|
|
41973
|
-
const minLength =
|
|
41974
|
-
const maxLength =
|
|
41975
|
-
if (typeof
|
|
42020
|
+
const minLength = options.minLength || 5;
|
|
42021
|
+
const maxLength = options.maxLength || 35;
|
|
42022
|
+
if (typeof options.temperature !== "undefined" && options.temperature <= 0) {
|
|
41976
42023
|
throw Error("Temperature option must be greater than 0");
|
|
41977
42024
|
}
|
|
41978
|
-
let tries = 0, tokens = []
|
|
42025
|
+
let tries = 0, tokens = [];
|
|
41979
42026
|
let minIdx = 0, sentenceIdxs = [];
|
|
41980
42027
|
let markedNodes = [];
|
|
41981
42028
|
const unmarkNodes = () => {
|
|
@@ -42014,7 +42061,7 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42014
42061
|
return false;
|
|
42015
42062
|
}
|
|
42016
42063
|
let flatSent = this.untokenize(sentence);
|
|
42017
|
-
if (!
|
|
42064
|
+
if (!options.allowDuplicates && isSubArray(sentence, tokens.slice(0, sentIdx))) {
|
|
42018
42065
|
fail("duplicate (pop: " + next.token + ")");
|
|
42019
42066
|
return false;
|
|
42020
42067
|
}
|
|
@@ -42101,7 +42148,7 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42101
42148
|
return len ? sentenceIdxs[len - 1] : 0;
|
|
42102
42149
|
};
|
|
42103
42150
|
const selectStart = () => {
|
|
42104
|
-
let seed =
|
|
42151
|
+
let seed = options.seed;
|
|
42105
42152
|
if (seed && seed.length) {
|
|
42106
42153
|
if (typeof seed === "string")
|
|
42107
42154
|
seed = this.tokenize(seed);
|
|
@@ -42131,7 +42178,7 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42131
42178
|
continue;
|
|
42132
42179
|
}
|
|
42133
42180
|
let parent = this._pathTo(tokens);
|
|
42134
|
-
let next = this._selectNext(parent,
|
|
42181
|
+
let next = this._selectNext(parent, options.temperature, tokens, notMarked);
|
|
42135
42182
|
if (!next) {
|
|
42136
42183
|
fail("mlm-fail(" + this.mlm + ")", this._flatten(tokens), true);
|
|
42137
42184
|
continue;
|
|
@@ -42150,13 +42197,22 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42150
42197
|
}
|
|
42151
42198
|
unmarkNodes();
|
|
42152
42199
|
let str = this.untokenize(tokens.map((t) => t.token)).trim();
|
|
42153
|
-
return
|
|
42200
|
+
return returnsArray ? this._splitEnds(str) : str;
|
|
42154
42201
|
}
|
|
42202
|
+
/**
|
|
42203
|
+
* Converts the model to a JSON-formatted string for storage or serialization
|
|
42204
|
+
* @return {string} - the JSON string
|
|
42205
|
+
*/
|
|
42155
42206
|
toJSON() {
|
|
42156
42207
|
let data = Object.keys(this).reduce((acc, k) => Object.assign(acc, { [k]: this[k] }), {});
|
|
42157
42208
|
data.sentenceEnds = [...data.sentenceEnds];
|
|
42158
42209
|
return stringify(data);
|
|
42159
42210
|
}
|
|
42211
|
+
/**
|
|
42212
|
+
* Creates a new model from one previously saved as JSON
|
|
42213
|
+
* @param {string} json - the JSON string to load
|
|
42214
|
+
* @return {RiMarkov} - the RiMarkov instance
|
|
42215
|
+
*/
|
|
42160
42216
|
static fromJSON(json) {
|
|
42161
42217
|
let parsed = parse(json);
|
|
42162
42218
|
let rm = Object.assign(new _RiMarkov(), parsed);
|
|
@@ -42167,7 +42223,13 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42167
42223
|
populate(rm.root = new Node(null, "ROOT"), jsonRoot);
|
|
42168
42224
|
return rm;
|
|
42169
42225
|
}
|
|
42170
|
-
|
|
42226
|
+
/**
|
|
42227
|
+
* Returns array of possible tokens after pre and (optionally) before post. If only one array parameter is provided, this function returns all possible next words, ordered by probability, for the given array.
|
|
42228
|
+
* If two arrays are provided, it returns an unordered list of possible words w that complete the n-gram consisting of: pre[0]...pre[k], w, post[k+1]...post[n].
|
|
42229
|
+
* @param {string[]} pre - the list of tokens preceding the completion
|
|
42230
|
+
* @param {string[]} [post] - the (optional) list of tokens following the completion
|
|
42231
|
+
* @return {string[]} - an unordered list of possible next tokens
|
|
42232
|
+
*/
|
|
42171
42233
|
completions(pre, post) {
|
|
42172
42234
|
let tn, result = [];
|
|
42173
42235
|
if (post) {
|
|
@@ -42191,8 +42253,14 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42191
42253
|
}
|
|
42192
42254
|
return result;
|
|
42193
42255
|
}
|
|
42194
|
-
|
|
42195
|
-
|
|
42256
|
+
/**
|
|
42257
|
+
* Returns the full set of possible next tokens as a object, mapping tokens to probabilities,
|
|
42258
|
+
* given an array of tokens representing the path down the tree (with length less than `n`).
|
|
42259
|
+
* @param {string|string[]} path - the path to the node as a string or an array of tokens
|
|
42260
|
+
* @param {number} [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.
|
|
42261
|
+
* @return {object} - a map of tokens to probabilities
|
|
42262
|
+
*/
|
|
42263
|
+
probabilities(path, temperature) {
|
|
42196
42264
|
if (!Array.isArray(path))
|
|
42197
42265
|
path = this.tokenize(path);
|
|
42198
42266
|
const probs = {};
|
|
@@ -42200,11 +42268,17 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42200
42268
|
if (parent) {
|
|
42201
42269
|
const children = parent.childNodes();
|
|
42202
42270
|
const weights = children.map((n) => n.count);
|
|
42203
|
-
const pdist = _RiMarkov.parent.randomizer.ndist(weights,
|
|
42271
|
+
const pdist = _RiMarkov.parent.randomizer.ndist(weights, temperature);
|
|
42204
42272
|
children.forEach((c, i) => probs[c.token] = pdist[i]);
|
|
42205
42273
|
}
|
|
42206
42274
|
return probs;
|
|
42207
42275
|
}
|
|
42276
|
+
/**
|
|
42277
|
+
* Returns either the raw (unigram) probability for a single token in the model (0 if it does not exist), OR
|
|
42278
|
+
* the probability of a sequence of K tokens where K is less than `n` (0 if the sequence does not exist).
|
|
42279
|
+
* @param {string|string[]} data - the token or array of tokens to check
|
|
42280
|
+
* @return {number} - the probability of the token or sequence
|
|
42281
|
+
*/
|
|
42208
42282
|
probability(data) {
|
|
42209
42283
|
let p = 0;
|
|
42210
42284
|
if (data && data.length) {
|
|
@@ -42214,10 +42288,20 @@ var _RiMarkov = class _RiMarkov {
|
|
|
42214
42288
|
}
|
|
42215
42289
|
return p;
|
|
42216
42290
|
}
|
|
42291
|
+
/**
|
|
42292
|
+
* Returns a string representation of the model or a subtree of the model, optionally ordered by probability.
|
|
42293
|
+
* @param {object} root - the root node of the subtree to print
|
|
42294
|
+
* @param {boolean} sort - if true, sort the nodes by probability
|
|
42295
|
+
* @return {string} - the string representation of the model
|
|
42296
|
+
*/
|
|
42217
42297
|
toString(root, sort) {
|
|
42218
42298
|
root = root || this.root;
|
|
42219
42299
|
return root.asTree(sort).replace(/{}/g, "");
|
|
42220
42300
|
}
|
|
42301
|
+
/**
|
|
42302
|
+
* Returns the number of tokens currently in the model.
|
|
42303
|
+
* @return {number} - number of tokens
|
|
42304
|
+
*/
|
|
42221
42305
|
size() {
|
|
42222
42306
|
return this.root.childCount(true);
|
|
42223
42307
|
}
|
|
@@ -42490,14 +42574,13 @@ var MULTI_SP_RE = / +/g;
|
|
|
42490
42574
|
var markov_default = RiMarkov;
|
|
42491
42575
|
|
|
42492
42576
|
// src/rita.js
|
|
42493
|
-
import { RiScript } from "riscript";
|
|
42494
|
-
var { Grammar: RiGrammar } = RiScript;
|
|
42577
|
+
import { RiScript, RiGrammar } from "riscript";
|
|
42495
42578
|
var RiTa = class _RiTa {
|
|
42496
42579
|
/**
|
|
42497
42580
|
* Create a RiTa grammar instance
|
|
42498
|
-
* @param {object} rules - the rules of the grammar
|
|
42499
|
-
* @param {object} context - the context of the grammar
|
|
42500
|
-
* @returns {
|
|
42581
|
+
* @param {object} [rules] - the rules of the grammar
|
|
42582
|
+
* @param {object} [context] - the context of the grammar
|
|
42583
|
+
* @returns {RiGrammar} - a new RiGrammar instance
|
|
42501
42584
|
*/
|
|
42502
42585
|
static grammar(rules, context) {
|
|
42503
42586
|
return new RiGrammar(rules, context);
|
|
@@ -42535,9 +42618,9 @@ var RiTa = class _RiTa {
|
|
|
42535
42618
|
/**
|
|
42536
42619
|
* Evaluates the input script via the RiScript parser
|
|
42537
42620
|
* @param {string} script - the script to evaluate
|
|
42538
|
-
* @param {object} context - the context to evaluate the script ing
|
|
42621
|
+
* @param {object} [context] - the context to evaluate the script ing
|
|
42539
42622
|
* @param {object} [options] - options for the evaluation
|
|
42540
|
-
* @param {boolean} options.trace - whether to trace the evaluation
|
|
42623
|
+
* @param {boolean} [options.trace] - whether to trace the evaluation
|
|
42541
42624
|
* @returns {string} the result of the evaluation
|
|
42542
42625
|
*/
|
|
42543
42626
|
static evaluate(script, context, options) {
|
|
@@ -42547,6 +42630,13 @@ var RiTa = class _RiTa {
|
|
|
42547
42630
|
* Creates a new RiMarkov object
|
|
42548
42631
|
* @param {number} n - an int representing the n-factor of the markov chain
|
|
42549
42632
|
* @param {object} [options] - options for the markov chain
|
|
42633
|
+
* @param {string|string[]} [options.text] - a text string, or array of sentences, to add to the model (same as via model.addText()
|
|
42634
|
+
* @param {number} [options.maxLengthMatch] - # of words allowed in result to match a sequence in the input, default=∞
|
|
42635
|
+
* @param {number} [options.maxAttempts=999] - max attempts before to complete one ore more generations before erroring, default=999
|
|
42636
|
+
* @param {function} [options.tokenize] - custom tokenizer with tokenize() method, defaults to RiTa.tokenize()
|
|
42637
|
+
* @param {function} [options.untokenize] - custom untokenizer with untokenize() method, defaults to RiTa.untokenize()
|
|
42638
|
+
* @param {boolean} [options.disableInputChecks=false] - if true, allow result to be present in the input, default
|
|
42639
|
+
* @param {boolean} [options.trace] - output trace info to the console
|
|
42550
42640
|
* @returns {RiMarkov}
|
|
42551
42641
|
*/
|
|
42552
42642
|
static markov(n, options) {
|
|
@@ -42557,9 +42647,9 @@ var RiTa = class _RiTa {
|
|
|
42557
42647
|
* @overload
|
|
42558
42648
|
* @param {string} keyword
|
|
42559
42649
|
* @param {object} [options]
|
|
42560
|
-
* @param {number} options.numWords - the number of words to include in the context
|
|
42561
|
-
* @param {string} options.text - the text as input for the KWIC model
|
|
42562
|
-
* @param {string[]} options.words - the array of words to be used as input for the KWIC model
|
|
42650
|
+
* @param {number} [options.numWords] - the number of words to include in the context
|
|
42651
|
+
* @param {string} [options.text] - the text as input for the KWIC model
|
|
42652
|
+
* @param {string[]} [options.words] - the array of words to be used as input for the KWIC model
|
|
42563
42653
|
* @returns {string[]} all the occurrences of the keyword in the model, each with no more
|
|
42564
42654
|
* than 'numWords' words of context on either side
|
|
42565
42655
|
* @overload
|
|
@@ -42575,11 +42665,11 @@ var RiTa = class _RiTa {
|
|
|
42575
42665
|
* Creates a concordance, a list of words with their frequency of occurence, from the given text and options.
|
|
42576
42666
|
* @param {string} text - the text from which to create the concordance
|
|
42577
42667
|
* @param {object} [options] - options for the concordance
|
|
42578
|
-
* @param {boolean} options.ignoreCase=false - whether to ignore case when creating the concordance
|
|
42579
|
-
* @param {boolean} options.ignoreStopWords=false - whether to ignore stop words like
|
|
42668
|
+
* @param {boolean} [options.ignoreCase=false] - whether to ignore case when creating the concordance
|
|
42669
|
+
* @param {boolean} [options.ignoreStopWords=false] - whether to ignore stop words like
|
|
42580
42670
|
* 'the', 'and', 'a', 'of', etc, as specified in RiTa.STOP_WORDS
|
|
42581
|
-
* @param {boolean} options.ignorePunctuation=false - whether to ignore punctuation when creating the concordance
|
|
42582
|
-
* @param {string[]} options.wordsToIgnore=null - words to ignore when creating the concordance (alternate stop-words)
|
|
42671
|
+
* @param {boolean} [options.ignorePunctuation=false] - whether to ignore punctuation when creating the concordance
|
|
42672
|
+
* @param {string[]} [options.wordsToIgnore=null] - words to ignore when creating the concordance (alternate stop-words)
|
|
42583
42673
|
* @returns {object} the concordance, an object with words as keys and frequencies as values
|
|
42584
42674
|
*/
|
|
42585
42675
|
static concordance(text, options) {
|
|
@@ -42641,14 +42731,14 @@ var RiTa = class _RiTa {
|
|
|
42641
42731
|
* (length, syllable-count, phonemic pattern, stress pattern, part-of-speech, etc.).
|
|
42642
42732
|
* @param {(string|RegExp)} [pattern] - the pattern to match
|
|
42643
42733
|
* @param {object} [options]
|
|
42644
|
-
* @param {number} options.minLength=4 - the minimum length of the word
|
|
42645
|
-
* @param {number} options.maxLength=-1 - the maximum length of the word
|
|
42646
|
-
* @param {number} options.numSyllables=null - the number of syllables in the word
|
|
42647
|
-
* @param {number} options.limit=10 - the maximum number of results to retur
|
|
42648
|
-
* @param {string} options.pos=null - the part-of-speech of the word to return,
|
|
42734
|
+
* @param {number} [options.minLength=4] - the minimum length of the word
|
|
42735
|
+
* @param {number} [options.maxLength=-1] - the maximum length of the word
|
|
42736
|
+
* @param {number} [options.numSyllables=null] - the number of syllables in the word
|
|
42737
|
+
* @param {number} [options.limit=10] - the maximum number of results to retur
|
|
42738
|
+
* @param {string} [options.pos=null] - the part-of-speech of the word to return,
|
|
42649
42739
|
* either from the Penn tag set or the simplified tag set [a, r, v, n]
|
|
42650
|
-
* @param {RegExp} options.pattern=null - the spelling or phonemic pattern to match
|
|
42651
|
-
* @param {string} options.type=null - the type of regex or string pattern to match,
|
|
42740
|
+
* @param {RegExp} [options.pattern=null] - the spelling or phonemic pattern to match
|
|
42741
|
+
* @param {string} [options.type=null] - the type of regex or string pattern to match,
|
|
42652
42742
|
* options are 'stresses' or 'phones' or 'letters' (the default)
|
|
42653
42743
|
* @returns {string} a random word matching the criteria in the options object
|
|
42654
42744
|
*/
|
|
@@ -42660,12 +42750,12 @@ var RiTa = class _RiTa {
|
|
|
42660
42750
|
* their final stressed vowel and all following phonemes are identical.
|
|
42661
42751
|
* @param {string} word
|
|
42662
42752
|
* @param {object} [options]
|
|
42663
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
42664
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
42665
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
42666
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
42667
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
42668
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
42753
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
42754
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
42755
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
42756
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
42757
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
42758
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
42669
42759
|
* or the simplified tag set [a, r, v, n]
|
|
42670
42760
|
* @returns {Promise<string[]>} an array of rhymes that match criteria in the options object
|
|
42671
42761
|
*/
|
|
@@ -42687,12 +42777,12 @@ var RiTa = class _RiTa {
|
|
|
42687
42777
|
* of each word in the lexicon via a minimum-edit-distance metric.
|
|
42688
42778
|
* @param {string} word
|
|
42689
42779
|
* @param {object} [options]
|
|
42690
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
42691
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
42692
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
42693
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
42694
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
42695
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
42780
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
42781
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
42782
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
42783
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
42784
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
42785
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
42696
42786
|
* or the simplified tag set [a, r, v, n]
|
|
42697
42787
|
* @returns {Promise<string[]>} an array of alliterations matching criteria in the options object
|
|
42698
42788
|
*/
|
|
@@ -42703,7 +42793,7 @@ var RiTa = class _RiTa {
|
|
|
42703
42793
|
* Returns true if the word is in the lexicon, else false
|
|
42704
42794
|
* @param {string} word - the word to check
|
|
42705
42795
|
* @param {object} [options] - options for the search
|
|
42706
|
-
* @param {boolean} options.noDerivations=false - whether to ignore derivations and only search for raw words
|
|
42796
|
+
* @param {boolean} [options.noDerivations=false] - whether to ignore derivations and only search for raw words
|
|
42707
42797
|
* @returns {boolean} true if the word is in the lexicon, else false
|
|
42708
42798
|
*/
|
|
42709
42799
|
static hasWord(word, options) {
|
|
@@ -42713,7 +42803,7 @@ var RiTa = class _RiTa {
|
|
|
42713
42803
|
* Returns true if the word is an abbreviation, else false
|
|
42714
42804
|
* @param {string} input - the word to check
|
|
42715
42805
|
* @param {object} [options] - options for the search
|
|
42716
|
-
* @param {boolean} options.caseSensitive=false - whether to ignore case when checking for abbreviations
|
|
42806
|
+
* @param {boolean} [options.caseSensitive=false] - whether to ignore case when checking for abbreviations
|
|
42717
42807
|
* @returns {boolean} true if the word is an abbreviation, else false
|
|
42718
42808
|
*/
|
|
42719
42809
|
static isAbbrev(input, options) {
|
|
@@ -42739,12 +42829,12 @@ var RiTa = class _RiTa {
|
|
|
42739
42829
|
* to each word in the lexicon, returning the set of closest matches that also match the criteria in the options object.
|
|
42740
42830
|
* @param {string} word - the word to match
|
|
42741
42831
|
* @param {object} [options] - options for the search
|
|
42742
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
42743
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
42744
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
42745
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
42746
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
42747
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set or the simplified tag set [a, r, v, n]
|
|
42832
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
42833
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
42834
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
42835
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
42836
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
42837
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set or the simplified tag set [a, r, v, n]
|
|
42748
42838
|
* @returns {Promise<string[]>} an array of words matching the spelling pattern and criteria in the options object
|
|
42749
42839
|
*/
|
|
42750
42840
|
static async spellsLike(word, options) {
|
|
@@ -42755,13 +42845,13 @@ var RiTa = class _RiTa {
|
|
|
42755
42845
|
* to each word in the lexicon, returning the set of closest matches that also match the criteria in the options object.
|
|
42756
42846
|
* @param {string} word - the word to match
|
|
42757
42847
|
* @param {object} [options] - options for the search
|
|
42758
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
42759
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
42760
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
42761
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
42762
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
42763
|
-
* @param {boolean} options.matchSpelling=false
|
|
42764
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
42848
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
42849
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
42850
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
42851
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
42852
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
42853
|
+
* @param {boolean} [options.matchSpelling=false] if true will also attempt to match spelling by returning an intersection with RiTa.spellsLike()
|
|
42854
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
42765
42855
|
* or the simplified tag set [a, r, v, n]
|
|
42766
42856
|
* @returns {Promise<string[]>} an array of words matching the phonemic pattern and criteria in the options object
|
|
42767
42857
|
*/
|
|
@@ -42773,7 +42863,7 @@ var RiTa = class _RiTa {
|
|
|
42773
42863
|
* from the Penn tag set or the simplified tag set [a, r, v, n].
|
|
42774
42864
|
* @param {(string|string[])} word - the word or words to tag
|
|
42775
42865
|
* @param {object} [options] - options for the tagging
|
|
42776
|
-
* @param {boolean} options.simple - use simple tags (noun=n,verb=v,adverb=a,adjective=r)
|
|
42866
|
+
* @param {boolean} [options.simple] - use simple tags (noun=n,verb=v,adverb=a,adjective=r)
|
|
42777
42867
|
* @returns {string|string[]} - an array of part-of-speech tags for each word in the input
|
|
42778
42868
|
*/
|
|
42779
42869
|
static pos(word, options) {
|
|
@@ -42830,7 +42920,7 @@ var RiTa = class _RiTa {
|
|
|
42830
42920
|
* Tags the input string with part-of-speech tags, either from the Penn tag set or the simplified tag set [a, r, v, n].
|
|
42831
42921
|
* @param {string} sentence - the sentence to tag
|
|
42832
42922
|
* @param {object} [options] - options for the tagging
|
|
42833
|
-
* @param {boolean} options.simple=false - use the simplified tag set [a, r, v, n]
|
|
42923
|
+
* @param {boolean} [options.simple=false] - use the simplified tag set [a, r, v, n]
|
|
42834
42924
|
* @returns {string} the tagged sentence
|
|
42835
42925
|
*/
|
|
42836
42926
|
static posInline(sentence, options) {
|
|
@@ -42857,14 +42947,14 @@ var RiTa = class _RiTa {
|
|
|
42857
42947
|
* spelling, phonemes, stresses, part-of-speech, etc. If no regex or options are supplied, the full set of words is returned.
|
|
42858
42948
|
* @param {(string|RegExp)} [pattern] - the pattern to match
|
|
42859
42949
|
* @param {object} [options] - options for the search
|
|
42860
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
42861
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
42862
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
42863
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
42864
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
42865
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
42950
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
42951
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
42952
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
42953
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
42954
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
42955
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
42866
42956
|
* or the simplified tag set [a, r, v, n]
|
|
42867
|
-
* @param {string} options.type - the type of regex or string pattern to match, options are 'stresses'
|
|
42957
|
+
* @param {string} [options.type] - the type of regex or string pattern to match, options are 'stresses'
|
|
42868
42958
|
* or 'phones' or 'letters' (the default)
|
|
42869
42959
|
* @returns {Promise<string[]>} an array of words matching the criteria in both the pattern and the options object
|
|
42870
42960
|
*/
|
|
@@ -42876,13 +42966,13 @@ var RiTa = class _RiTa {
|
|
|
42876
42966
|
* Punctuation and case are ignored unless specified otherwise.
|
|
42877
42967
|
* @param {string} text - The text from which to extract the tokens
|
|
42878
42968
|
* @param {object} [options] - The options
|
|
42879
|
-
* @param {boolean} options.caseSensitive=false - Whether to pay attention to case
|
|
42880
|
-
* @param {boolean} options.ignoreStopWords=false - Whether to ignore words such as 'the', 'and', 'a', 'of', etc,
|
|
42969
|
+
* @param {boolean} [options.caseSensitive=false] - Whether to pay attention to case
|
|
42970
|
+
* @param {boolean} [options.ignoreStopWords=false] - Whether to ignore words such as 'the', 'and', 'a', 'of', etc,
|
|
42881
42971
|
* as specified in RiTa.STOP_WORDS
|
|
42882
|
-
* @param {boolean} options.splitContractions=false - Whether to convert contractions
|
|
42972
|
+
* @param {boolean} [options.splitContractions=false] - Whether to convert contractions
|
|
42883
42973
|
* (e.g., "I'd" or "she'll") into multiple individual tokens
|
|
42884
|
-
* @param {boolean} options.includePunct=false - Whether to include punctuation in the results
|
|
42885
|
-
* @param {boolean} options.sort=false - Whether to sort the tokens before returning them
|
|
42974
|
+
* @param {boolean} [options.includePunct=false] - Whether to include punctuation in the results
|
|
42975
|
+
* @param {boolean} [options.sort=false] - Whether to sort the tokens before returning them
|
|
42886
42976
|
* @returns {string[]} Array of tokens
|
|
42887
42977
|
*/
|
|
42888
42978
|
static tokens(text, options = {
|
|
@@ -42898,10 +42988,10 @@ var RiTa = class _RiTa {
|
|
|
42898
42988
|
* Tokenizes an input string into words, according to the Penn Treebank conventions
|
|
42899
42989
|
* @param {string} input - The text to tokenize
|
|
42900
42990
|
* @param {object} [options] - The options
|
|
42901
|
-
* @param {RegExp} options.regex=null - An optional custom regex to split on
|
|
42902
|
-
* @param {boolean} options.splitHyphens=false - Whether to split hyphenated words
|
|
42991
|
+
* @param {RegExp} [options.regex=null] - An optional custom regex to split on
|
|
42992
|
+
* @param {boolean} [options.splitHyphens=false] - Whether to split hyphenated words
|
|
42903
42993
|
* (e.g., "mother-in-law") into multiple individual tokens
|
|
42904
|
-
* @param {boolean} options.splitContractions=false - Whether to split contractions
|
|
42994
|
+
* @param {boolean} [options.splitContractions=false] - Whether to split contractions
|
|
42905
42995
|
* (e.g., "I'd" or "she'll") into multiple individual tokens
|
|
42906
42996
|
* @returns {string[]} Array of tokens
|
|
42907
42997
|
*/
|
|
@@ -42912,7 +43002,7 @@ var RiTa = class _RiTa {
|
|
|
42912
43002
|
* Joins an array (of words and punctuation) into a sentence, according to
|
|
42913
43003
|
* the Penn Treebank conventions. The inverse of RiTa.tokenize().
|
|
42914
43004
|
* @param {string[]} input - The array of words to join
|
|
42915
|
-
* @param {string} delim=' ' - The delimiter to use between words, or a space by default
|
|
43005
|
+
* @param {string} [delim=' '] - The delimiter to use between words, or a space by default
|
|
42916
43006
|
* @returns {string} The joined sentence
|
|
42917
43007
|
*/
|
|
42918
43008
|
static untokenize(input, delim = " ") {
|
|
@@ -42964,14 +43054,14 @@ var RiTa = class _RiTa {
|
|
|
42964
43054
|
* Conjugates the 'verb' according to the specified options (tense, person, number, etc.)
|
|
42965
43055
|
* @param {string} verbWord
|
|
42966
43056
|
* @param {object} [options]
|
|
42967
|
-
* @param {number} options.tense - the tense of the verb, either RiTa.PAST, RiTa.PRESENT, or RiTa.FUTURE
|
|
42968
|
-
* @param {number} options.person - the person of the verb, either RiTa.FIRST, RiTa.SECOND, or RiTa.THIRD
|
|
42969
|
-
* @param {number} options.number - the number of the verb, either RiTa.SINGULAR or RiTa.PLURAL
|
|
42970
|
-
* @param {number} options.form - the form of the verb, either RiTa.INFINITIVE or RiTa.GERUND
|
|
42971
|
-
* @param {boolean} options.passive - whether the verb should be passive
|
|
42972
|
-
* @param {boolean} options.progressive - whether the verb should be progressive
|
|
42973
|
-
* @param {boolean} options.perfect - whether the verb should be perfect
|
|
42974
|
-
* @param {boolean} options.interrogative - whether the verb should be in interrogative form
|
|
43057
|
+
* @param {number} [options.tense] - the tense of the verb, either RiTa.PAST, RiTa.PRESENT, or RiTa.FUTURE
|
|
43058
|
+
* @param {number} [options.person] - the person of the verb, either RiTa.FIRST, RiTa.SECOND, or RiTa.THIRD
|
|
43059
|
+
* @param {number} [options.number] - the number of the verb, either RiTa.SINGULAR or RiTa.PLURAL
|
|
43060
|
+
* @param {number} [options.form] - the form of the verb, either RiTa.INFINITIVE or RiTa.GERUND
|
|
43061
|
+
* @param {boolean} [options.passive] - whether the verb should be passive
|
|
43062
|
+
* @param {boolean} [options.progressive] - whether the verb should be progressive
|
|
43063
|
+
* @param {boolean} [options.perfect] - whether the verb should be perfect
|
|
43064
|
+
* @param {boolean} [options.interrogative] - whether the verb should be in interrogative form
|
|
42975
43065
|
* @returns {string} the conjugated verb
|
|
42976
43066
|
*/
|
|
42977
43067
|
static conjugate(verbWord, options) {
|
|
@@ -42980,6 +43070,7 @@ var RiTa = class _RiTa {
|
|
|
42980
43070
|
/**
|
|
42981
43071
|
* Analyzes the input and returns a new string containing the stresses for each syllable of the input text .
|
|
42982
43072
|
* @param {string} input - the text to analyze
|
|
43073
|
+
* @param {object} [options] - options for the analysis
|
|
42983
43074
|
* @returns {string} a string containing the stresses for each syllable of the input text
|
|
42984
43075
|
*/
|
|
42985
43076
|
static stresses(input, options) {
|
|
@@ -42988,6 +43079,7 @@ var RiTa = class _RiTa {
|
|
|
42988
43079
|
/**
|
|
42989
43080
|
* Analyzes the input and returns a new string containing the syllables of the input text.
|
|
42990
43081
|
* @param {string} input - the text to analyze
|
|
43082
|
+
* @param {object} [options] - options for the analysis
|
|
42991
43083
|
* @returns {string} a string containing the syllables of the input text
|
|
42992
43084
|
*/
|
|
42993
43085
|
static syllables(input, options) {
|
|
@@ -42996,6 +43088,7 @@ var RiTa = class _RiTa {
|
|
|
42996
43088
|
/**
|
|
42997
43089
|
* Analyzes the input and returns a new string containing the phonemes of the input text.
|
|
42998
43090
|
* @param {string} input - the text to analyze
|
|
43091
|
+
* @param {object} [options] - options for the analysis
|
|
42999
43092
|
* @returns {string} a string containing the phones of the input text
|
|
43000
43093
|
*/
|
|
43001
43094
|
static phones(input, options) {
|
|
@@ -43006,7 +43099,7 @@ var RiTa = class _RiTa {
|
|
|
43006
43099
|
* including phonemes, syllables, stresses, and part-of-speech tags.
|
|
43007
43100
|
* @param {string} input - the text to analyze
|
|
43008
43101
|
* @param {object} [options] - options for the analysis
|
|
43009
|
-
* @param {boolean} options.simple=false - whether to use the simplified tag set [a, r, v, n]
|
|
43102
|
+
* @param {boolean} [options.simple=false] - whether to use the simplified tag set [a, r, v, n]
|
|
43010
43103
|
* @returns {object} an object containing the features of the input text (phones, syllables, stresses, pos), or the features inline
|
|
43011
43104
|
*/
|
|
43012
43105
|
static analyze(input, options) {
|
|
@@ -43019,13 +43112,13 @@ var RiTa = class _RiTa {
|
|
|
43019
43112
|
* returning the set of closest matches that also match the criteria in the options object.
|
|
43020
43113
|
* @param {string} word - the word to match
|
|
43021
43114
|
* @param {object} [options] - options for the search
|
|
43022
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
43023
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
43024
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
43025
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
43026
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
43115
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
43116
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
43117
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
43118
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
43119
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
43027
43120
|
* or the simplified tag set [a, r, v, n]
|
|
43028
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
43121
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
43029
43122
|
* @return {string[]} an array of words matching the spelling pattern and criteria in the options object
|
|
43030
43123
|
*/
|
|
43031
43124
|
static spellsLikeSync(word, options) {
|
|
@@ -43036,13 +43129,13 @@ var RiTa = class _RiTa {
|
|
|
43036
43129
|
* to each word in the lexicon, returning the set of closest matches that also match the criteria in the options object.
|
|
43037
43130
|
* @param {string} word - the word to match
|
|
43038
43131
|
* @param {object} [options] - options for the search
|
|
43039
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
43040
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
43041
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
43042
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
43043
|
-
* @param {boolean} options.matchSpelling=false
|
|
43044
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
43045
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
43132
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
43133
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
43134
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
43135
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
43136
|
+
* @param {boolean} [options.matchSpelling=false] if true will also attempt to match spelling by returning an intersection with RiTa.spellsLike()
|
|
43137
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
43138
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
43046
43139
|
* or the simplified tag set [a, r, v, n]
|
|
43047
43140
|
* @return {string[]} an array of words matching the phonemic pattern and criteria in the options object
|
|
43048
43141
|
*/
|
|
@@ -43054,12 +43147,12 @@ var RiTa = class _RiTa {
|
|
|
43054
43147
|
* Two words are considered as rhyming if their final stressed vowel and all following phonemes are identical.
|
|
43055
43148
|
* @param {string} word - the word to match
|
|
43056
43149
|
* @param {object} [options] - options for the search
|
|
43057
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
43058
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
43059
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
43060
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
43061
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
43062
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
43150
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
43151
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
43152
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
43153
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
43154
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
43155
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
43063
43156
|
* or the simplified tag set [a, r, v, n]
|
|
43064
43157
|
* @return {string[]} an array of rhymes that match criteria in the options object
|
|
43065
43158
|
*/
|
|
@@ -43072,14 +43165,14 @@ var RiTa = class _RiTa {
|
|
|
43072
43165
|
* part-of-speech, etc.
|
|
43073
43166
|
* @param {(string|RegExp)} [pattern] - the pattern to match
|
|
43074
43167
|
* @param {object} [options] - options for the search
|
|
43075
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
43076
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
43077
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
43078
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
43079
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
43080
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
43168
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
43169
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
43170
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
43171
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
43172
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
43173
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
43081
43174
|
* or the simplified tag set [a, r, v, n]
|
|
43082
|
-
* @param {string} options.type - the type of regex or string pattern to match, options are 'stresses' or 'phones' or 'letters' (the default)
|
|
43175
|
+
* @param {string} [options.type] - the type of regex or string pattern to match, options are 'stresses' or 'phones' or 'letters' (the default)
|
|
43083
43176
|
* @return {string[]} an array of words matching the criteria in both the pattern and the options object
|
|
43084
43177
|
*/
|
|
43085
43178
|
static searchSync(pattern, options) {
|
|
@@ -43090,12 +43183,12 @@ var RiTa = class _RiTa {
|
|
|
43090
43183
|
* of the input string to those of each word in the lexicon via a minimum-edit-distance metric.
|
|
43091
43184
|
* @param {string} word - the word to match
|
|
43092
43185
|
* @param {object} [options] - options for the search
|
|
43093
|
-
* @param {number} options.minLength=4 - the minimum length of the words
|
|
43094
|
-
* @param {number} options.maxLength - the maximum length of the words
|
|
43095
|
-
* @param {number} options.numSyllables - the number of syllables in the words
|
|
43096
|
-
* @param {number} options.limit=10 - the maximum number of results to return (pass -1 to return all matches)
|
|
43097
|
-
* @param {boolean} options.shuffle=false - whether to shuffle the results before returning them
|
|
43098
|
-
* @param {string} options.pos - the part-of-speech of the words to return, either from the Penn tag set
|
|
43186
|
+
* @param {number} [options.minLength=4] - the minimum length of the words
|
|
43187
|
+
* @param {number} [options.maxLength] - the maximum length of the words
|
|
43188
|
+
* @param {number} [options.numSyllables] - the number of syllables in the words
|
|
43189
|
+
* @param {number} [options.limit=10] - the maximum number of results to return (pass -1 to return all matches)
|
|
43190
|
+
* @param {boolean} [options.shuffle=false] - whether to shuffle the results before returning them
|
|
43191
|
+
* @param {string} [options.pos] - the part-of-speech of the words to return, either from the Penn tag set
|
|
43099
43192
|
* or the simplified tag set [a, r, v, n]
|
|
43100
43193
|
* @return {string[]} an array of alliterations matching criteria in the options object
|
|
43101
43194
|
*/
|
|
@@ -43143,7 +43236,7 @@ markov_default.parent = RiTa;
|
|
|
43143
43236
|
stemmer_default.tokenizer = RiTa.tokenizer;
|
|
43144
43237
|
RiTa.SILENT = false;
|
|
43145
43238
|
RiTa.SILENCE_LTS = false;
|
|
43146
|
-
RiTa.VERSION = "3.0.
|
|
43239
|
+
RiTa.VERSION = "3.0.25";
|
|
43147
43240
|
RiTa.FIRST = 1;
|
|
43148
43241
|
RiTa.SECOND = 2;
|
|
43149
43242
|
RiTa.THIRD = 3;
|
|
@@ -43170,9 +43263,9 @@ RiTa.GERUND = 2;
|
|
|
43170
43263
|
RiTa.SPLIT_CONTRACTIONS = false;
|
|
43171
43264
|
var ONLY_PUNCT = /^[\p{P}|\+|-|<|>|\^|\$|\ufffd|`]*$/u;
|
|
43172
43265
|
var IS_LETTER = /^[a-z\u00C0-\u00ff]+$/;
|
|
43173
|
-
RiTa.RiScript = RiScript;
|
|
43174
43266
|
RiTa.riscript = new RiScript({ RiTa });
|
|
43175
43267
|
export {
|
|
43268
|
+
markov_default as RiMarkov,
|
|
43176
43269
|
RiTa
|
|
43177
43270
|
};
|
|
43178
43271
|
//# sourceMappingURL=rita.js.map
|