我正在尝试使用 spaCy 训练基本文本分类模型。我有一个文本列表,我想构建一个模型,将文本分类为outcome1或outcome2。假设我的数据如下所示:
texts = ["This is the first example text",
"This is the second example text",
"This is yet another text"]
y = ["outcome2", "outcome1", "outcome1"]
Run Code Online (Sandbox Code Playgroud)
我的问题是,我什至无法将文本处理成文档:
nlp = spacy.blank("en")
textcat = nlp.create_pipe("textcat")
textcat.add_label("outcome1")
textcat.add_label("outcome2")
textcat = nlp.add_pipe("textcat", last = True)
nlp.pipe_names
Run Code Online (Sandbox Code Playgroud)
>>> ['textcat']
Run Code Online (Sandbox Code Playgroud)
但是当我尝试处理任何文本时,我收到错误:
doc = nlp("This is a sentence")
Run Code Online (Sandbox Code Playgroud)
>>> ValueError: Cannot get dimension 'nO' for model 'sparse_linear': value unset
Run Code Online (Sandbox Code Playgroud)
我尝试按照本教程(有点过时)并使用spaCy 快速启动小部件设置一个项目,但在初始化配置文件时我不断遇到错误。我缺少什么?