Esempio n. 1
0
def main():

    # Number of files expected
    number_of_files = int(input("How many files are being input: "))

    # Makes the object
    ACP = AutocompleteProvider()

    for i in range(number_of_files):

        # This is the file given by the user it has the passages already written
        train_file = input(
            "Please enter the name of the file you want to use to train: ")

        # This is the string entered by the user who wants some suggestions
        word = input("Please enter a word: ")

        # trains on the target file
        ACP.train(train_file)

        # Finds possbile words, sorts them, then dumps them
        print("Here are some suggestions after one file")
        words = ACP.getWords(word)
        sorted_words = ACP.quicksort(words)
        ACP.dump(sorted_words)
def main():

    # This is the file given by the user it has the passages already written
    train_file = input("Please enter the name of the file you want to use to train: ")

    # This is the string entered by the user who wants some suggestions
    word = input("Please enter a word: ")

    # Builds the object and trains on the target file
    ACP = AutocompleteProvider()
    ACP.train(train_file)

    # Finds possbile words, sorts them, then dumps them
    print("Here are some suggestions")
    words = ACP.getWords(word)
    sorted_words = ACP.quicksort(words)
    ACP.dump(sorted_words)
Esempio n. 3
0
from Candidate import Candidate
from Trie import Trie

if __name__ == '__main__':

    autoComplete = AutocompleteProvider()

    while True:
        userInput = input('\n\t0: Quit the program.\n' \
                          '\t1: Train autocomplete program.\n' \
                          '\t2: Retrieve next predicted word list.\n' \
                          '\t3: Clear autocomplete program\'s history.\n' \
                          'Select from the options above: ')
        if userInput == "0":
            print("Program ended.")
            break
        elif userInput == "1":
            passage = input("Enter passage to train autocomplete program: ")
            autoComplete.train(passage)
        elif userInput == "2":
            fragment = input("Enter fragment to get autocomplete entries: ")
            wordList = []
            autoComplete.getWords(fragment, wordList)
            for candidate in wordList:
                print(candidate)
        elif userInput == "3":
            del autoComplete
            autoComplete = AutocompleteProvider()
        else:
            print("Invalid input.")