快速文本TypeError::不兼容的函数参数

问题描述

我正尝试使用受监督的快速文本分类器来训练我的分类器系统,如下所示:
我的txt文件的头是:

__label__0A001 0a001 “nuclear reactors” and specially designed or prepared equipment and components therefor,as follows: a. “nuclear reactors”; b. Metal vessels,or major shopfabricated parts therefor,including the reactor vessel head for a reactor pressure vessel,specially designed or prepared to contapin the core of a “nuclear reactor”;  
__label__0B001 0b001 plant for the separation of isotopes of “natural uranium”,“depleted uranium” and “special fissile materials”,and specially designed or prepared equipment and components therefor,other than analytical instruments,as follows: a. plant specially designed for separating isotopes of “natural uranium”,“depleted uranium”,and “special fissile materials”
import fasttext
model = fasttext.train_supervised(input='myfile.txt')

但是,出现此错误

Traceback (most recent call last):
  File "C:/Users/u5712005/PycharmProjects/recognize_dsgl_risky_research/Risky_researcher_DSGL/recognize_dsgl_risky_research/fasttext_main.py",line 53,in <module>
    model = fasttext.train_supervised(input=path.lookuptable_keyphrases_fasttext)
  File "C:\Users\u5712005\Anaconda3\lib\site-packages\fasttext\FastText.py",line 529,in train_supervised
    a = _build_args(args,manually_set_args)
  File "C:\Users\u5712005\Anaconda3\lib\site-packages\fasttext\FastText.py",line 421,in _build_args
    setattr(a,k,v)
TypeError: (): incompatible function arguments. The following argument types are supported:
    1. (self: fasttext_pybind.args,arg0: str) -> None

Invoked with: <fasttext_pybind.args object at 0x0000020F3B47EEF0>,WindowsPath('C:/Users/u5712005/PycharmProjects/recognize_dsgl_risky_research/Risky_researcher_DSGL/data/Output_data/DSG_lookup_fasttext_table.txt')

有什么建议吗?

马西

解决方法

您似乎正在使用Windows操作系统。 main Facebook FastText page说:

通常,fastText建立在现代Mac OS和Linux发行版上。

official Python wrapper页面显示:

fastText建立在现代Mac OS和Linux发行版上。由于它使用C ++ 11功能,因此需要具有良好C ++ 11支持的编译器。您将需要Python(2.7或≥3.4版),NumPy&SciPy和pybind11。

在这些页面上我没有提到Windows支持,因此核心程序包可能没有经过设计或测试,无法在Windows上直接使用。

仔细研究该项目的Github问题,有许多与尝试在Windows上运行有关的未解决和未解决的问题。有些人通过额外的步骤或可能使用其他来源的非官方轮子来提及成功。

如果您需要使用Windows,则搜索这些问题可能会很幸运。

如果您不需要使用Windows,则许多Python数据科学堆栈都经过了更好的测试,并在MacOS或Linux上得到了支持。