# xAAL commands in natural language * Objective The idea is to perform xAAL actions while entering sentences in natural language. (Tests are performed for french.) For instance: « majordome allume la lumière » (i.e. "Majordom, switch on light!") sends an xAAL query on devices "lamp.*" with method "on". Matching is based on synonyms and on fuzzy rules, allowing some sligly differents requests arround the nominal ones. This piece of code can then be pluged to a speech-to-text software. * A naive algorithm . A pre-defined dictionnary of translations associates a set of words from the natural language to a target word in the xAAL language. For instance: { target:"lamp.*", sources: [ "lampe", "lumière", "ampoule", ... ] } { target:"on", sources: [ "allume", "éclaire", ... ] } { target:"off", sources: [ "étins", "ferme", ... ] } . A pre-defined dictionnary of expected commands associates a set of words of the xAAL language to a function that performs an xAAL action. For instance: { "xaal_light_on()", words: [ "lamp.*", "on" ] } { "xaal_light_off()", words: [ "lamp.*", "off" ] } . Each token of the entered query in natural laguage is compared to each source word of the dictionnary of translations. The (fuzzy) matching score (between 0.0 an 1.0) and the target translated word are memorised in a data structure. . For each expected commands a score is computed by multiplying the score of each of its corresponding words that are present in the above data structure. . If the score of the best command is acceptable (typically greather than 3/5), then the corresponding xAAL action is executed. * Discussion . Pro: this is naive but verry simple ;-) . Cons: pre-defined dictionnaries are hardcoded for now. A future release may load them from configuration files. . A more smart release could feed dictionnaries with tags associated to xAAL devices in order to dynamically identify the right device from the entered sentence.