快速文本类型错误:():函数参数不兼容

2024-06-16 13:31:13 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试使用fasttext监督分类器训练我的分类器系统,如下所示:
我的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')

有什么建议吗

马西


Tags: orandofthetxtargsusersnuclear
1条回答
网友
1楼 · 发布于 2024-06-16 13:31:13

看起来您正在使用Windows操作系统。报告说:

Generally, fastText builds on modern Mac OS and Linux distributions.

它的official Python wrapper页面上写着:

fastText builds on modern Mac OS and Linux distributions. Since it uses C++11 features, it requires a compiler with good C++11 support. You will need Python (version 2.7 or ≥ 3.4), NumPy & SciPy and pybind11.

我在这些页面上没有看到任何关于Windows支持的内容,所以有可能核心软件包没有经过设计或测试,无法在Windows上开箱即用

纵观该项目的Github问题,有许多与在Windows上运行它相关的开放和封闭问题。有些人提到成功,通过额外的步骤或可能通过使用其他来源的非官方车轮

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

如果您不需要使用Windows,那么Python数据科学堆栈的大部分都经过了更好的测试;在MacOS或Linux上受支持

相关问题 更多 >