$nlp.fixKeyboardLayout
The method corrects the text by changing the layout from Latin to Cyrillic.
Syntax
- ECMAScript 5
- ECMAScript 6
$nlp.fixKeyboardLayout("Ghbdtn!"); // => "Привет!"
In the ECMAScript 6 runtime, the method is asynchronous
await $nlp.fixKeyboardLayout("Ghbdtn!"); // => "Привет!"
The method accepts a string and returns it in Cyrillic layout.
For example, for Ghbdtn!
the method returns Привет!
.
caution
-
If there are Cyrillic characters in the string, the method returns
null
. -
If you pass to the method an object instead of a string, the function returns
хщиоусе Щиоусеъ
, because it changes the layout of the line[object Object]
.
How to use
Use it in combination with $nlp.match
:
- ECMAScript 5
- ECMAScript 6
theme: /
state: Hello
intent!: /hello
a: match
state: CatchAll
event!: noMatch
script:
var text = $parseTree.text;
$temp.fixedText = $nlp.fixKeyboardLayout(text);
# Call $nlp.match if we got the fixed string
if: $temp.fixedText
script:
var matchResults = $nlp.match($temp.fixedText, "/");
// If we found a state, transition to it
if (matchResults){
$parseTree = matchResults.parseTree;
var nextState = matchResults.targetState;
$reactions.transition(nextState);
};
a: I do not understand
theme: /
state: Hello
intent!: /hello
a: match
state: CatchAll
event!: noMatch
scriptEs6:
const text = $parseTree.text;
$temp.fixedText = await $nlp.fixKeyboardLayout(text);
# Call $nlp.match if we got the fixed string
if: $temp.fixedText
script:
var matchResults = $nlp.match($temp.fixedText, "/");
// If we found a state, transition to it
if (matchResults){
$parseTree = matchResults.parseTree;
var nextState = matchResults.targetState;
$reactions.transition(nextState);
};
a: I do not understand