首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >正确安装nlp

正确安装nlp
EN

Stack Overflow用户
提问于 2021-10-15 10:41:50
回答 1查看 34关注 0票数 0

我的代码:

代码语言:javascript
复制
import nlp
def tokenize_sentences(text):
    tokens = nlp(text)
    sentences = [sent.text for sent in nlp(text).sents]
    return sentences
text = "Some phrases that I use as a test. The context is not important. Test sentence.

sentences = tokenize_sentences(text)

错误是:

代码语言:javascript
复制
TypeError                                 Traceback (most recent call last)
<ipython-input-4-ec796e2a8070> in <module>
----> 1 sentences = tokenize_sentences(text)

<ipython-input-2-aa259d17fc09> in tokenize_sentences(text)
      1 def tokenize_sentences(text):
----> 2     tokens = nlp(text)
      3     sentences = [sent.text for sent in nlp(text).sents]
      4     #print(sentences)
      5     #for sent in tokens.sents:

TypeError: 'module' object is not callable

我又试着安装了!pip install NLP-python!pip install NLP!pip install nlp。然后,当我尝试下面的,'NLP‘没有找到。

代码语言:javascript
复制
from NLP import NLP
nlp = NLP()

我知道错误在进口的某个地方,但我不知道在哪里。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-10-15 10:55:45

从代码中的属性判断,您要寻找的库似乎不是NLP-python,而是spacy

代码语言:javascript
复制
pip3 install spacy
python3 -m spacy download en_core_web_sm

然后在您的代码中:

代码语言:javascript
复制
import spacy
nlp = spacy.load("en_core_web_sm")
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69583487

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档