【发布时间】:2021-11-21 21:49:56
【问题描述】:
我正在使用FastText.load_fasttext_format()在 Google Colab 中加载 fastText 官方日语训练模型(300 暗淡)。
这是我的代码。
model_path = "/content/drive/MyDrive/IDR/rakuten/wikipedia_fastText/cc.ja.300.bin"
model = FastText.load_fasttext_format(model_path)
这是编码错误。
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-7-61d7c85f09b2> in <module>()
2
3 model_path = "/content/drive/MyDrive/IDR/rakuten/wikipedia_fastText/cc.ja.300.bin"
----> 4 model = FastText.load_fasttext_format(model_path)
2 frames
/usr/local/lib/python3.7/dist-packages/gensim/models/fasttext.py in _load_dict(self, file_handle, encoding)
818 word_bytes += char_byte
819 char_byte = file_handle.read(1)
--> 820 word = word_bytes.decode(encoding)
821 count, _ = self.struct_unpack(file_handle, '@qb')
822
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 0: unexpected end of data
【问题讨论】:
标签: python unicode encoding utf-8 fasttext