Esempio n. 1
0
    def _compile_literal(self, element, *args, **kwargs):
        # Build literals as sequences and use <NULL> for unknown words.
        children = []
        for word in element.words:
            if self.engine.check_valid_word(word):
                children.append(jsgf.Literal(word))
            else:
                children.append(
                    self.compile_element(elements_.Impossible(), *args,
                                         **kwargs))

                # Save the unknown word.
                args[1].add(word)

        return jsgf.Sequence(*children)
Esempio n. 2
0
 def _compile_dictation(self, element, *args, **kwargs):
     return self.compile_element(elements_.Impossible(), *args, **kwargs)
Esempio n. 3
0
 def _compile_dictation(self, element, *args, **kwargs):
     # JSGF has no equivalent for dictation elements. Instead compile and
     # return an Impossible element that allows dictation to be used,
     # but not matched.
     return self.compile_element(elements_.Impossible(), *args, **kwargs)