2022-09-13 17:38:10 +08:00
|
|
|
|
mindspore.dataset.text.FastText
|
|
|
|
|
|
================================
|
|
|
|
|
|
|
|
|
|
|
|
.. py:class:: mindspore.dataset.text.FastText
|
|
|
|
|
|
|
2022-10-29 15:23:09 +08:00
|
|
|
|
用于将tokens映射到向量的FastText对象。
|
2022-09-13 17:38:10 +08:00
|
|
|
|
|
|
|
|
|
|
.. py:method:: from_file(file_path, max_vectors=None)
|
|
|
|
|
|
|
2022-09-22 16:55:54 +08:00
|
|
|
|
从文件构建FastText向量。
|
2022-09-13 17:38:10 +08:00
|
|
|
|
|
|
|
|
|
|
参数:
|
2022-10-29 15:23:09 +08:00
|
|
|
|
- **file_path** (str) - 包含向量的文件路径。预训练向量集的文件后缀必须是 `*.vec` 。
|
2022-09-13 17:38:10 +08:00
|
|
|
|
- **max_vectors** (int,可选) - 用于限制加载的预训练向量的数量。
|
2022-10-29 15:23:09 +08:00
|
|
|
|
大多数预训练的向量集是按词频降序排序的。因此,如果内存不能存放整个向量集,或者由于其他原因不需要,
|
2022-09-13 17:38:10 +08:00
|
|
|
|
可以传递 `max_vectors` 限制加载数量。默认值:None,无限制。
|
|
|
|
|
|
|
|
|
|
|
|
返回:
|
2022-09-22 16:55:54 +08:00
|
|
|
|
FastText, 根据文件构建的FastText向量。
|
2022-10-29 15:23:09 +08:00
|
|
|
|
|
|
|
|
|
|
异常:
|
|
|
|
|
|
- **RuntimeError** - `file_path` 参数所指向的文件非法或者包含的数据异常。
|
|
|
|
|
|
- **ValueError** - `max_vectors` 参数值错误。
|
|
|
|
|
|
- **TypeError** - `max_vectors` 参数不是整数类型。
|