Constructor
new LanguageModel(parent)
Properties:
Name | Type | Description | ||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
word_predict_base_url |
string | The api address for querying word predictions for a given left context and prefix. |
||||||||||||||||||||||||||||||||||||||||||
word_predict_char_future_url |
string | Used for forward caching. The api address for querying word predictions for a given left context and prefix, for each possible next character that could be added to the prefix. |
||||||||||||||||||||||||||||||||||||||||||
word_predict_word_future_url |
string | Used for forward caching. The api address for querying word predictions for a given left context and prefix, for each possible next word prediction that could be added to the prefix. |
||||||||||||||||||||||||||||||||||||||||||
char_predict_base_url |
string | The api address for querying character probabilities for a given left context and prefix. |
||||||||||||||||||||||||||||||||||||||||||
char_predict_char_future_url |
string | Used for forward caching. The api address for querying character probabilities for a given left context and prefix, for each possible next character that could be added to the prefix. |
||||||||||||||||||||||||||||||||||||||||||
char_predict_word_future_url |
string | Used for forward caching. The api address for querying character probabilities for a given left context and prefix, for each possible next word prediction that could be added to the prefix. |
||||||||||||||||||||||||||||||||||||||||||
lm_prefix |
string | The prefix for the word currently being typed. For example: If the user has typed "I am using Nomo", the lm_prefix would be "Nomo". |
||||||||||||||||||||||||||||||||||||||||||
left_context |
string | The left-context for the word currently being typed. For example: If the user has typed "I am using Nomo", the lm_prefix would be "I am using ". |
||||||||||||||||||||||||||||||||||||||||||
word_cache |
Object.<Object.<Object>> | A nested Object maintaining a cache of all possible future word and character probabilities that are one selection away. First level keys are the letters a-z, punctuation, current word predictions, and corrective options: Properties
|
||||||||||||||||||||||||||||||||||||||||||
word_predictions |
Array.<Array.<string>> | 2D Array containing the word predictions for the currently typed left-contect and prefix. Of the form: [[word_a1, word_a2, word_a3], [word_b1, word_b2, word_b3], ...] |
||||||||||||||||||||||||||||||||||||||||||
word_prediction_probs |
Array.<Array.<number>> | 2D Array containing the probabilities of the current word predictions. |
Parameters:
Name | Type | Description |
---|---|---|
parent |
Keyboard | The instance of the main Keyboard class. |
Methods
construct_url(base, parameters) → {String}
- Description:
Helper function to add the parameters in an object to a URL string.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
base |
String | The base URL. |
parameters |
Object | An object with parameter keys and values to add to the base URL string. |
Returns:
- Returns a new URL string with the added parameters.
- Type
- String
foramt_words(words_li, temp_prefix) → {Object}
- Description:
Helper function. Formats the word predictions and probabilities into Arrays useable by the Nomon inference module.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
words_li |
Array.<String> | An array of word predictions from the language model. |
temp_prefix |
String | The prefix to store the words and probabilities under in the word cache. |
Returns:
- Returns a formatted Object with the word predictions and probabilities.
- Type
- Object
format_chars(chars_li) → {Array.<Number>}
- Description:
Helper function. Formats the probabilities of the main characters into an Array useable by the Nomon inference module.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
chars_li |
Array.<String> | An Array of the possible main characters (kconfig.main_chars). |
Returns:
- The probabilities of the main characters from the language model.
- Type
- Array.<Number>
on_cor_load_function(output, cache_type)
- Description:
Runs when an API query Promise is completed. Adds the results to their corresponding place in the future word cache.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
output |
JSON | The data returned from the API call. |
cache_type |
String | The type of API query submitted: "word_base", "char_base", "word_future_char", "word_future_word", "char_future_char", or "char_future_word" |
update_cache(left, prefix, selection)
- Description:
Update the future word cache given the newest selection in the keyboard. Creates Promises to complete when the API returns results.
- Source:
Parameters:
Name | Type | Default | Description |
---|---|---|---|
left |
String | The current left context from the keyboard. |
|
prefix |
String | The current prefix from the keyboard. |
|
selection |
String | null |
null
|
The currently selected option that triggered the cache update (null for cache init) |