How to use the nlu.generators.__init__.Generator function in nlu

To help you get started, we’ve selected a few nlu examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github JoshRosen / cmps140_creative_cooking_assistant / nlu / generators / __init__.py View on Github external
def __init__(self, cache_size, generators):
        Generator.__init__(self, cache_size, generators)
        self.tokenizer = nltk.TreebankWordTokenizer()
github JoshRosen / cmps140_creative_cooking_assistant / nlu / generators / __init__.py View on Github external
return result

    def _generate(self, raw_input_string, generators):
        raise NotImplementedError


class Generate_Tokenized_String(Generator):
    def __init__(self, cache_size, generators):
        Generator.__init__(self, cache_size, generators)
        self.tokenizer = nltk.TreebankWordTokenizer()
        
    def _generate(self, raw_input_string, generators):
        return self.tokenizer.tokenize(raw_input_string)


class Generate_Stanford_Parse_Tree(Generator):
    def _generate(self, raw_input_string, generators):
        generate_tokenized_string = generators.generate_tokenized_string
        tokenized_string = generate_tokenized_string(raw_input_string)
        return get_parse_tree(tokenized_string)
github JoshRosen / cmps140_creative_cooking_assistant / nlu / generators / __init__.py View on Github external
# try and lookup cache
        cached_result = self._getCached(raw_input_string)
        if cached_result:
            # return cached result
            return cached_result
        else:
            # generate, insert into cache, return result
            result = self._generate(raw_input_string, self.generators)
            self._putCached(raw_input_string, result)
            return result

    def _generate(self, raw_input_string, generators):
        raise NotImplementedError


class Generate_Tokenized_String(Generator):
    def __init__(self, cache_size, generators):
        Generator.__init__(self, cache_size, generators)
        self.tokenizer = nltk.TreebankWordTokenizer()
        
    def _generate(self, raw_input_string, generators):
        return self.tokenizer.tokenize(raw_input_string)


class Generate_Stanford_Parse_Tree(Generator):
    def _generate(self, raw_input_string, generators):
        generate_tokenized_string = generators.generate_tokenized_string
        tokenized_string = generate_tokenized_string(raw_input_string)
        return get_parse_tree(tokenized_string)