def predictive_text(dico):
    """Predictive text for mobile phones

    :param dico: associates weights to words from [a-z]*
    :returns: a dictionary associating to words from [2-9]*
             a corresponding word from the dictionary with highest weight
    :complexity: linear in total word length
    """
    freq = {}   # freq[p] = poids total des mots de préfixe p
    for mot, poids in dico:
        prefixe = ""
        for x in mot:
            prefixe += x
            if prefixe in freq:
                freq[prefixe] += poids
            else:
                freq[prefixe] = poids
    #   prop[s] = préfixe à afficher sur s
    prop = {}
    for prefixe in freq:
        code = mot_code(prefixe)
        if code not in prop or freq[prop[code]] < freq[prefixe]:
            prop[code] = prefixe
    return prop
dataset/ETHPy150Open jilljenn/tryalgo/tryalgo/predictive_text.py/predictive_text/original