我已经使用“python -m spacy download de_core_news_sm”安装了“de_core_news_sm”,它安装成功我也使用“python -m spacy validate”验证了它但是我仍然不能在我的代码中使用这个模型我不断收到这个错误:“OSError:[E050] 找不到模型‘de_core_news_sm’。它似乎不是 Python 包或数据目录的有效路径。”我该如何解决,以下是我的代码:
import spacy
# Load the pre-trained German and English language models
nlp_de = spacy.load('de_core_news_sm')
nlp_en = spacy.load("en_core_web_sm")
# Example word to check
word = "hello"
# Check if the word is valid in German
doc_de = nlp_de(word)
if len(doc_de) == 1 and not doc_de[0].is_stop and doc_de[0].is_alpha:
print(f"{word} is not a valid word in German.")
else:
print(f"{word} is a valid word in German.")
# Check if the word is valid in English
doc_en = nlp_en(word)
if len(doc_en) == 1 and not doc_en[0].is_stop and doc_en[0].is_alpha:
print(f"{word} is a valid word in English.")
else:
print(f"{word} is not a valid word in English.")
• 无法从 spacy 加载英语语言模型(Jupyter Notebook | Python 3.9)
• Spacy Entity Linker with Transformer Listener 问题
• 我想将 errant 与 spacy v3 一起使用...errant 不适用于 spacy v3
• 重新训练从 Azure CustomVision.ai 获得的预训练模型
• 无法从配置文件加载模型:找不到 [nlp] 部分。 {'spacy': {'model': 'en_core_web_sm'}}
• attribute tuple doc.ents is writable in spacy?
• PrefixLM 预训练目标和 PrefixLM 类型架构
• 能否在每个时间步使用其连续预测输出作为输入来训练 RNN?
• 使用我的自定义数据集微调 Pixel2Style2Pixel 模型
• 如何统一公平地评价不同预训练语言模型在同一任务上的性能指标?
• 如何在训练 Huggingface Transformers (Pegasus) 模型时防止 VRAM 中途丢失?
• 错误 "IndexError: 如何在Keras中使用训练好的模型预测输入图像?
• sklearn RandomForestRegressor:可训练参数的数量
• 我在一个脚本中训练了一个 LSTM 分类器 (TF),加载到另一个脚本中,它对相同的数据给出了不同的预测?
• 带有自定义训练循环和 tf.data.dataset 的 tensorflow