Constructor Summary
Public Constructor | ||
public |
constructor(params: Object) |
Member Summary
Public Members | ||
public |
dictionaries: * |
|
public |
dictionary: {...undefined: Object, ...dict: Object} |
|
public |
morse2textD: {} |
|
public |
options: * |
|
public |
text2morseD: {} |
Method Summary
Public Methods | ||
public |
display(tokens: Array, charSpace: String, wordSpace: String, map: Map, errors: Array, errorPrefix: String, errorSuffix: String): * General method for converting a set of tokens to a displayable string |
|
public |
displayMorse(morseTokens: *): * |
|
public |
displayMorseErrors(morseTokens: *, errorTokens: *, prefix: *, suffix: *): * |
|
public |
displayText(textTokens: Array, escapeMap: Map): * Convert from text tokens to displayable String |
|
public |
displayTextErrors(textTokens: *, escapeMap: *, errorTokens: *, prefix: *, suffix: *): * |
|
public |
looksLikeMorse(input: *): * |
|
public |
morse2text(morse: *): * |
|
public |
morseTokens2text(morseTokens: *): {"morse": *, "text": *, "error": *, "hasError": *} |
|
public |
setDictionaries(dictList: List) Set the list of dictionaries to use. |
|
public |
setDictionariesAndOptions(dictList: *, optionList: *) |
|
public |
setOptions(optionList: List) Set the list of dictionary options to use. |
|
public |
text2morse(text: *): * |
|
public |
text2morseClean(text: *): * |
|
public |
textTokens2morse(textTokens: Array): * |
|
public |
Tidies text (upper case, trim, squash multiple spaces) |
|
public |
tokeniseMorse(morse: *): * |
|
public |
tokeniseRawText(text: String): * Splits text into words and letters |
|
public |
tokeniseText(text: String): * Tidies and then tokenises text |
Private Methods | ||
private |
_addDictionary(dict: Object) Load in a dictionary. |
|
private |
_input2output(tokens: *, dict: *): * |
|
private |
|
Public Constructors
public constructor(params: Object) source
Params:
Name | Type | Attribute | Description |
params | Object | dictionary of optional parameters. |
|
params.dictionary | String |
|
which dictionary to use, e.g. 'international' or 'american'. Can optionally take a list of dictionary strings. |
params.dictionaryOptions | String[] |
|
optional additional dictionaries such as 'prosigns'. Will look these up in the merged dictionary formed of the list of dictionaries. |
Public Members
public dictionaries: * source
public morse2textD: {} source
public options: * source
public text2morseD: {} source
Public Methods
public display(tokens: Array, charSpace: String, wordSpace: String, map: Map, errors: Array, errorPrefix: String, errorSuffix: String): * source
General method for converting a set of tokens to a displayable string
Params:
Name | Type | Attribute | Description |
tokens | Array | list of lists of tokens to form into String |
|
charSpace | String | String to use to separate characters |
|
wordSpace | String | String to use to separate words |
|
map | Map | Map to replace tokens with alternatives, e.g. for display escaping {'>', '>'} |
|
errors | Array | list if lists of Booleans indicating if there is an error in the tokens parameter |
|
errorPrefix | String | used to prefix any token that is an error |
|
errorSuffix | String | used to suffix any token that is an error |
Return:
* | a String of the tokens |
public displayMorse(morseTokens: *): * source
Params:
Name | Type | Attribute | Description |
morseTokens | * |
Return:
* |
public displayMorseErrors(morseTokens: *, errorTokens: *, prefix: *, suffix: *): * source
Params:
Name | Type | Attribute | Description |
morseTokens | * | ||
errorTokens | * | ||
prefix | * | ||
suffix | * |
Return:
* |
public displayText(textTokens: Array, escapeMap: Map): * source
Convert from text tokens to displayable String
Return:
* | a String, joining the characters together, separating the words with a space |
public displayTextErrors(textTokens: *, escapeMap: *, errorTokens: *, prefix: *, suffix: *): * source
Params:
Name | Type | Attribute | Description |
textTokens | * | ||
escapeMap | * | ||
errorTokens | * | ||
prefix | * | ||
suffix | * |
Return:
* |
public morseTokens2text(morseTokens: *): {"morse": *, "text": *, "error": *, "hasError": *} source
Params:
Name | Type | Attribute | Description |
morseTokens | * |
Return:
{"morse": *, "text": *, "error": *, "hasError": *} |
public setDictionaries(dictList: List) source
Set the list of dictionaries to use.
Params:
Name | Type | Attribute | Description |
dictList | List | list of dictionary names |
public setDictionariesAndOptions(dictList: *, optionList: *) source
Params:
Name | Type | Attribute | Description |
dictList | * | ||
optionList | * |
public setOptions(optionList: List) source
Set the list of dictionary options to use.
Params:
Name | Type | Attribute | Description |
optionList | List | list of dictionary option names. Looked up in merged dictionary |
public textTokens2morse(textTokens: Array): * source
Params:
Name | Type | Attribute | Description |
textTokens | Array | list of lists of text tokens |
Return:
* | Map - text: text tokens, morse: morse tokens, error: error tokens, hasError Boolean |
public tidyText(text: String): * source
Tidies text (upper case, trim, squash multiple spaces)
Params:
Name | Type | Attribute | Description |
text | String | the text to tidy |
Return:
* | the tidied text |
public tokeniseRawText(text: String): * source
Splits text into words and letters
Params:
Name | Type | Attribute | Description |
text | String | the text to tokenise |
Return:
* | a list of lists, e.g. [['o', 'n', 'e'], ['t', 'w', 'o']] |
public tokeniseText(text: String): * source
Tidies and then tokenises text
Params:
Name | Type | Attribute | Description |
text | String | the text to tokenise |
Return:
* | the tidied, tokenised text |
Private Methods
private _addDictionary(dict: Object) source
Load in a dictionary. Dictionary needs 'letter' and (optional) 'letterMatch' keys.
Params:
Name | Type | Attribute | Description |
dict | Object |
private _input2output(tokens: *, dict: *): * source
Params:
Name | Type | Attribute | Description |
tokens | * | ||
dict | * |
Return:
* |