DataPredict

API Reference - Others - Tokenizer

Tokenizer is used to tokenize items such as text, number and so on. It also includes a number of useful functions for converting between tokens and items.

Constructors

new()

Creates a new tokenizer object.

Tokenizer.new(tokenizedItemArray: []): TokenizerObject

Parameters:

Returns:

Functions

addItem()

Adds an item to be tokenized. If the item already exists, then it will ignore the item.

Tokenizer:addItem(item: any)

Parameters:

addAllItems()

Tokenize all items in the item array. If an item already exists, then it will ignore that item.

Tokenizer:addAllItems(itemArray: [])

Parameters:

convertTokenToItem()

Gets the item from a given token number. If no item is found from the given token number, then it will return nil.

Tokenizer:convertTokenToItem(tokenNumber: integer): any

Parameters:

Returns:

convertItemToToken()

Gets the token number from a given item. If no item is found, then it will return nil.

Tokenizer:convertItemToToken(item: any): integer

Parameters:

Returns:

getTokenizedItemArray()

Gets an array of tokenized items from the tokenizer object.

Tokenizer:getTokenizedItemArray(): []

Returns:

setTokenizedItemArray()

Sets an array of tokenized items to the tokenizer object.

Tokenizer:setTokenizedItemArray(tokenizedItemArray: [])

Parameters: