API Reference

A list of the full API reference of all public classes and functions is below.

Core Classes

class GraphTransliterator(settings)

Create a GraphTransliterator.

Arguments
  • settings (Object) –

GraphTransliterator.isWhitespace(token)

Check if a token is whitespace.

Returns

boolean

GraphTransliterator.lastMatchedRuleTokens

Get the last tokens matched.

GraphTransliterator.lastMatchedRules

Get the last rules matched.

GraphTransliterator.matchAllAt(tokenIdx, tokens)

Match all tokens at a particular index.

Arguments
  • tokenIdx (number) –

  • tokens (Array) –

Returns

undefined|Array – List of rule indexes

GraphTransliterator.matchAt(tokenIdx, tokens, matchAll=false)

Match best (least costly) transliteration rule at a given index in the input tokens and return the index to that rule. Optionally, return all rules that match.

Arguments
  • tokenIdx (number) – Location in tokens at which to begin

  • tokens (Array) – List of strings of tokens

  • matchAll (boolean) – If true, return the index of all rules matching at the given index. The default is false.

Returns

(undefined|number|Array) - Index of rule matched or list of rules matched

GraphTransliterator.tokenize(input)

Tokenize input string.

Arguments
  • input (string) – Input string

Returns

Array – - match details

GraphTransliterator.transliterate(input)

Transliterate an input string into an output string.

Whitespace will be temporarily appended to start and end of input string.

Arguments
  • input (string) –

Throws

UnrecognizableInputTokenError

Returns

string – Transliterated input string.

GraphTransliterator.fromDict(dictSettings)

Create a GraphTransliterator from settings. (From Python implementation, can be removed.)

Arguments
  • dictSettings (object) – Compressed on decompressed settings.

Returns

GraphTransliterator

class DirectedGraph(edge, node, edge_list)

DirectedGraph

Graph data structure used in Graph Transliterator.

Arguments
  • edge (object) – Mapping from head to tail of edge, holding edge data

  • node (Array) – Array of node attributes

  • edge_list (Array) – Array of head and tail of each edge

DirectedGraph.addEdge(head, tail, edgeData)

Add new edge.

Arguments
  • head (number) – Index of head of edge

  • tail (number) – Index of tail of edge

  • edgeData (Object) – Attributes of edge

Returns

Object – - Reference to new edge

DirectedGraph.addNode(nodeData)
Arguments
  • nodeData (object) – Attributes for node

Returns

Array.<number, number> – - Index of new node

Bundled Transliterators

class Example()

Example transliterator

class ITRANSDevanagariToUnicode()

ITRANSDevanagariToUnicode transliterator

Errors

class GraphTransliteratorError()

Base Graph Transliterator error.

class NoMatchingTransliterationRuleError()

Graph Transliterator no matching transliteration rule error.

class UnrecognizableInputTokenError()

Graph Transliterator unrecognizable token error.