Example #1
0
def run_test(input_data):
    trie = lab.generate_trie(input_data["words"])
    if input_data["f"] == "autocorrect":  # Tests for correct autocorrect
        return lab.autocorrect(trie, input_data["prefix"], input_data["N"])
    if input_data["f"] == "autocomplete":  # Tests for correct autocomplete
        return lab.autocomplete(trie, input_data["prefix"], input_data["N"])
    else:  # Tests just for producing the trie
        return trie
Example #2
0
def run_test( input_data ):
  trie = lab.generate_trie(input_data["words"])
  if input_data["f"] == "autocorrect": # Tests for correct autocorrect
      return lab.autocorrect(trie, input_data["prefix"], input_data["N"])
  if input_data["f"] == "autocomplete": # Tests for correct autocomplete
      return lab.autocomplete(trie, input_data["prefix"], input_data["N"])
  else: # Tests just for producing the trie
      return trie
Example #3
0
def autocorrect(input_data):
    global trie
    if trie is None:
        words = []
        print "LOADING CORPUS"
        with open("resources/words.json", "r") as f:
            words = json.load(f)
            trie = lab.generate_trie(words)
    return lab.autocorrect(trie, input_data["prefix"], input_data["N"])
Example #4
0
def autocorrect( input_data ):
   global trie
   if trie is None:
       words = []
       print "LOADING CORPUS"
       with open("resources/words.json", "r") as f:
           words = json.load(f)
           trie = lab.generate_trie(words)
   return lab.autocorrect(trie, input_data["prefix"], input_data["N"])