Skip to main content

$nlp.fixKeyboardLayout

The method corrects the text by changing the layout from Latin to Cyrillic. Accepts a string, returns a formatted string.

tip
For example, for the string ghbdtn it will return привет.
Parameters

If there are Cyrillic characters in the text, returns null. No formatting is applied to numbers.

caution
If you call this function without parameters, the bot fails with an error.
tip
If you pass to the function an object instead of a string, the function returns хщиоусе щиоусеъ, because it changes the layout of the line [object Object].
How to use
 state:
q!: *
a: {{ $nlp.fixKeyboardLayout($parseTree.text) }}

Use in combination with $nlp.match:

state: Hello
q!: (hello/what’s up/good morning)
a: И тебе {{ $parseTree.text }}!

state: CatchAll
q!: *
script:
var text = $parseTree.text;
$temp.fixedText = $nlp.fixKeyboardLayout(text);

if: $temp.fixedText

script:
var matchResults = $nlp.match($temp.fixedText, "/");
$parseTree = matchResults.parseTree;
$temp.nextState = matchResults.targetState;

go!: {{ $temp.nextState }}
else:
a: I did not understand...