Home Reference Source Repository
import Morse from 'morse-pro/src/morse-pro.js'
public class | source

Morse

Direct Subclass:

MorseCW

Constructor Summary

Public Constructor
public

constructor(params: Object)

Member Summary

Public Members
public
public

dictionary: {...undefined: Object, ...dict: Object}

public
public

options: *

public

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

tidyText(text: String): *

Tidies text (upper case, trim, squash multiple spaces)

public

tokeniseMorse(morse: *): *

public

Splits text into words and letters

public

tokeniseText(text: String): *

Tidies and then tokenises text

Private Methods
private

Load in a dictionary.

private

_input2output(tokens: *, dict: *): *

private

Public Constructors

public constructor(params: Object) source

Params:

NameTypeAttributeDescription
params Object

dictionary of optional parameters.

params.dictionary String
  • optional
  • default: 'international'

which dictionary to use, e.g. 'international' or 'american'. Can optionally take a list of dictionary strings.

params.dictionaryOptions String[]
  • optional
  • default: []

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 dictionary: {...undefined: Object, ...dict: Object} 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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
morseTokens *

Return:

*

public displayMorseErrors(morseTokens: *, errorTokens: *, prefix: *, suffix: *): * source

Params:

NameTypeAttributeDescription
morseTokens *
errorTokens *
prefix *
suffix *

Return:

*

public displayText(textTokens: Array, escapeMap: Map): * source

Convert from text tokens to displayable String

Params:

NameTypeAttributeDescription
textTokens Array

list of lists representing the words and characters

escapeMap Map

Map to replace tokens with alternatives, e.g. for display escaping {'>', '>'}

Return:

*

a String, joining the characters together, separating the words with a space

public displayTextErrors(textTokens: *, escapeMap: *, errorTokens: *, prefix: *, suffix: *): * source

Params:

NameTypeAttributeDescription
textTokens *
escapeMap *
errorTokens *
prefix *
suffix *

Return:

*

public looksLikeMorse(input: *): * source

Params:

NameTypeAttributeDescription
input *

Return:

*

public morse2text(morse: *): * source

Params:

NameTypeAttributeDescription
morse *

Return:

*

public morseTokens2text(morseTokens: *): {"morse": *, "text": *, "error": *, "hasError": *} source

Params:

NameTypeAttributeDescription
morseTokens *

Return:

{"morse": *, "text": *, "error": *, "hasError": *}

public setDictionaries(dictList: List) source

Set the list of dictionaries to use.

Params:

NameTypeAttributeDescription
dictList List

list of dictionary names

public setDictionariesAndOptions(dictList: *, optionList: *) source

Params:

NameTypeAttributeDescription
dictList *
optionList *

public setOptions(optionList: List) source

Set the list of dictionary options to use.

Params:

NameTypeAttributeDescription
optionList List

list of dictionary option names. Looked up in merged dictionary

public text2morse(text: *): * source

Params:

NameTypeAttributeDescription
text *

Return:

*

public text2morseClean(text: *): * source

Params:

NameTypeAttributeDescription
text *

Return:

*

public textTokens2morse(textTokens: Array): * source

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
text String

the text to tidy

Return:

*

the tidied text

public tokeniseMorse(morse: *): * source

Params:

NameTypeAttributeDescription
morse *

Return:

*

public tokeniseRawText(text: String): * source

Splits text into words and letters

Params:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
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:

NameTypeAttributeDescription
dict Object

private _input2output(tokens: *, dict: *): * source

Params:

NameTypeAttributeDescription
tokens *
dict *

Return:

*

private _loadDictionaries() source