我一直在尝试使用 PyCharm 练习从本教程中学到的知识:( https://realpython.com/sentiment-analysis-python/ )。
还有这一行:
textcat.add_label("pos")
Run Code Online (Sandbox Code Playgroud)
生成警告: 无法在“(Doc) -> Doc | ”中找到引用“add_label” (文档)-> 文档'
我知道这是因为“ nlp.create_pipe() ”生成一个文档而不是字符串,但是(本质上是因为我不知道在这种情况下该怎么做!)无论如何我都运行了脚本,但后来我得到了一个错误从这一行:
textcat = nlp.create_pipe("textcat", config={"architecture": "simple_cnn"})
Run Code Online (Sandbox Code Playgroud)
错误消息:
raise ConfigValidationError(
thinc.config.ConfigValidationError:
Config validation error
textcat -> architecture extra fields not permitted
{'nlp': <spacy.lang.en.English object at 0x0000015E74F625E0>, 'name': 'textcat', 'architecture': 'simple_cnn', 'model': {'@architectures': 'spacy.TextCatEnsemble.v2', 'linear_model': {'@architectures': 'spacy.TextCatBOW.v1', 'exclusive_classes': True, 'ngram_size': 1, 'no_output_layer': False}, 'tok2vec': {'@architectures': 'spacy.Tok2Vec.v2', 'embed': {'@architectures': 'spacy.MultiHashEmbed.v1', 'width': 64, 'rows': [2000, 2000, 1000, 1000, 1000, 1000], 'attrs': ['ORTH', 'LOWER', 'PREFIX', 'SUFFIX', 'SHAPE', 'ID'], …Run Code Online (Sandbox Code Playgroud)