<s> __all__ = [ "<STR_LIT>" , "<STR_LIT>" ] <EOL> t9 = "<STR_LIT>" <EOL> def lettre_chiffre ( x ) : <EOL> """<STR_LIT>""" <EOL> assert '<STR_LIT:a>' <= x <= '<STR_LIT:z>' <EOL> return t9 [ ord ( x ) - ord ( '<STR_LIT:a>' ) ] <EOL> def mot_code ( mot ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' . join ( map ( lettre_chiffre , mot ) ) <EOL> def predictive_text ( dico ) : <EOL> """<STR_LIT>""" <EOL> freq = { } <EOL> for mot , poids in dico : <EOL> prefixe = "<STR_LIT>" <EOL> for x in mot : <EOL> prefixe += x <EOL> if prefixe in freq : <EOL> freq [ prefixe ] += poids <EOL> else : <EOL> freq [ prefixe ] = poids <EOL> prop = { } <EOL> for prefixe in freq : <EOL> code = mot_code ( prefixe ) <EOL> if code not in prop or freq [ prop [ code ] ] < freq [ prefixe ] : <EOL> prop [ code ] = prefixe <EOL> return prop <EOL> def propose ( prop , seq ) : <EOL> """<STR_LIT>""" <EOL> if seq in prop : <EOL> return prop [ seq ] <EOL> else : <EOL> return "<STR_LIT:None>" </s>
