ユニコード文字列から句読点を削除する必要があります。私はいくつかの投稿を読んで、最も推奨されたものはthis oneでした。unicodeから句読点を削除する:
私は次のように実装しました:
table = dict.fromkeys(i for i in range(sys.maxunicode) if unicodedata.category(chr(i)).startswith('P'))
def tokenize(message):
message = unicode(message,'utf-8').lower()
#print message
message = remove_punctuation_unicode(message)
return message
def remove_punctuation_unicode(string):
return string.translate(table)
をしかし、私は、コードを実行すると、このエラーがポップアップ表示されます:
table = dict.fromkeys(i for i in range(sys.maxunicode) if unicodedata.category(chr(i)).startswith('P'))
TypeError: must be unicode, not str
私はかなり何をすべきか、それを把握することはできません。誰かがこれを修正する方法を教えてもらえますか?
あなたは、Pythonのバージョンは何を使用していますか? – rvs
@rvs Python 2.7 – Krishh