私は千行のイタリア語のテキストを読み、ユニークな単語の辞書を作成しています。句読点を削除する 2 つの方法を試しました。
for p in string.punctuation:
word = word.replace(p, str())
また :
for line in f:
for word in line.split():
stripped_text =""
for char in word:
if char in '!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~>><<<<?>>?123456789':
char = ''
stripped_text += char
私の問題は、これにはまだ句読点が含まれていることです:
{'<<Dicerolti': 1,'piage>>.': 1,'succia?>>.': 1,…}
何かアイデアはありますか?