データのセットがありますが、データのみを処理する必要があるため、記号utf-8
以外のすべてのデータを削除する必要があります。utf-8
これらのファイルを操作しようとすると、次のようになります。
UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 3062: character maps to <undefined> and UnicodeDecodeError: 'utf8' codec can't decode byte 0xc1 in position 1576: invalid start byte
私のコード
class Corpus:
def __init__(self,path_to_dir=None):
self.path_to_dir = path_to_dir if path_to_dir else []
def emails_as_string(self):
for file_name in os.listdir(self.path_to_dir):
if not file_name.startswith("!"):
with io.open(self.add_slash(self.path_to_dir)+file_name,'r', encoding ='utf-8') as body:
yield[file_name,body.read()]
def add_slash(self, path):
if path.endswith("/"): return path
return path + "/"
yield[file_name,body.read()]
私はこことここでエラーを受け取りますlist_of_emails = mailsrch.findall(text)
が、utf-8を使用するとすべて素晴らしいです。