import os
import math


def get_all_texts(datapath):
    """ (string) -> dict of {string: string}

    Return a dictionary where the keys are disease names
    and the values are the contents of the file key.html
    from the directory datapath.
    """
    
    # get a list of all the filenames in the directory
    filenames = os.listdir(datapath)
    
    # dictionary of all texts, keys are disease names
    disease_to_text= {}
    
    for filename in filenames:

        # read the entire file's contents as a string
        text = open(homefolder + filename).read()

        # since all the filenames end in .html, just drop that part
        disease = filename.split(".")[0]

        # insert it into the dictionary
        disease_to_text[disease] = text
    
    return disease_to_text
    

datapath = "/home/guerzhoy/Desktop/diagnosis/wikipages/"    

# before you can call this function, you need to write functions for 
#   clean_up_file
#   query  
# and define global variable homefolder
def interface():
    while True:
        q = clean_up_file(input("query: ")).split()
        print("Best match:", query(homefolder, q))

