Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, cache_size, generators):
Generator.__init__(self, cache_size, generators)
self.tokenizer = nltk.TreebankWordTokenizer()
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)
# 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)