-3
Code:
while True:
regras, numero_frases = map(int, input().split())
if regras == 0 and numero_frases == 0:
break
dici = {}
for r in range(regras):
subs = input().replace(' ', '').split('->')
dici[subs[0]] = subs[1]
if subs[0] == 0 and subs[1] == 0:
break
for f in range(numero_frases):
frase = input().split()
for p in frase:
if p in dici:
frase[frase.index(p)] = dici[p]
print(*frase)
Entree:
2 3 (número de regras e frases)
Rat -> Rato (substituições)
Rome -> Roma
O Rat roeu ( A saída deve ser a frase baseada na troca da regra)
a roupa do rei
de Rome
1 1
e -> i
e o vento levou
0 0
exit:
O Rato roeu
a roupa do rei
de Roma
i o vinto livou
The code corrects words or single letters, but I want it to also work with letters in the words, grateful!
I know the words get organized into trie and if any word in a sentence cannot be found in the distance Levenshtein to determine candidates for replacement within the trie. Now this way what is doing is against producent because in addition to inform the correct words you in thesis would have to inform all the possibility of spelling errors for each word inserted. Insert two substitution rules is simple the hard is to create a 1000 word dictionary.
– Augusto Vasques