Exemple #1
0
def loadfiles():
    Dictionary.loadDictionary('dictionary')
    global suffixes, modals, person, imperitive

    file = FileHandler.loadFile("Resources/person.csv", "r")
    for line in file:
        line = line.strip()
        p = line.split(',')
        print(len(p))
        person.update({p[0]: [p[1], p[2], p[3], p[4], p[5], p[6], p[7]]})
    file.close()
    file = FileHandler.loadFile("Resources/modals.csv", "r")
    for line in file:
        line = line.strip()
        p = line.split(',')
        modals.update({p[0]: [p[1]]})
    file.close()
    file = FileHandler.loadFile("Resources/suffixes.csv", "r")
    for line in file:
        line = line.strip()
        p = line.split(',')
      #  print(str(p))
        suffixes.update({p[0]: [p[1]]})
    file.close()
    file = FileHandler.loadFile("Resources/imperative.csv", "r")
    for line in file:
        line = line.strip()
        p = line.split(',')
        imperitive.update({p[0]: [ p[1], p[2], p[3], p[4]]})
def loadDictionary(language):
    """

    :param language:
    :return:
    """
    global mode
    mode = language
    file = FileHandler.loadFile("Resources/" + language + ".csv", "r")
    for line in file:
        vals = line.split(',')
        # check to make sure their not blank
        if vals[0] == '':
            continue
        value = ""
        for i in range(1, len(vals)):
            if vals[i].strip() != '' and vals[i] is not None:
                value += vals[i].strip() + " ,"
        ret = {vals[0].strip(): value.strip()}
        dictionary.update(ret)

    #create the reverse
    for key, value in dictionary.items():
        vals = value.split(",")
        for v in vals:
           translation.update({v.strip(): key})
    print("**************** Dictionary File Loaded ****************")
    return dictionary
def loadPhrases():
    ###TODO: klingon
    file = FileHandler.loadFile('Resources/CommonPhrases.csv', 'r')
    for line in file:
        details = line.split(';')
        print(details)
        values = ""
        for x in range(1, len(details)):
            values +=details[x].strip()+ ","

        entry = {details[0]: values}
        phrases.update(entry)
def loadDictionary(language):
    global mode
    mode = language
    file = FileHandler.loadFile("Resources/" + language + ".csv", "r")
    for line in file:
        vals = line.split(',')
        # check to make sure their not blank
        if vals[0] == '':
            continue
        value = ""

        for i in range(1, len(vals)):
            if vals[i].strip() != '':
                value += vals[i].strip() + ","
        dictionary.update({vals[0].strip(): value.strip()})

        translation.update({value.strip(): vals[0].strip()})

    print("**************** Dictionary Loaded ****************")
    return dictionary