无法导入名称“combined_rule_sentence_segmenter”

问题描述 投票:0回答:2

我已经安装了所有的软件包。导入它们时出现“无法导入名称'combined_rule_sentence_segmenter'”之类的错误。如何正确导入包。

!pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.0/en_core_sci_sm-0.2.0.tar.gz
pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.0/en_core_sci_md-0.2.0.tar.gz
pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.0/en_ner_bc5cdr_md-0.2.0.tar.gz
pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.0/en_ner_bionlp13cg_md-0.2.0.tar.gz

import scispacy
import spacy
from spacy import displacy
from collections import Counter
import en_core_web_sm
import en_ner_bc5cdr_md
import en_core_sci_sm
import en_core_sci_md
import en_ner_bionlp13cg_md
from scispacy.abbreviation import AbbreviationDetector
from scispacy.umls_linking import UmlsEntityLinker
from collections import OrderedDict
from pprint import pprint


/usr/local/lib/python3.6/dist-packages/spacy/util.py:275: UserWarning: [W031] Model 'en_core_web_sm' (2.2.5) requires spaCy v2.2 and is incompatible with the current spaCy version (2.3.2). This may lead to unexpected results or runtime errors. To resolve this, download a newer compatible model or retrain your custom model with the current spaCy version. For more details and available updates, run: python -m spacy validate
  warnings.warn(warn_msg)
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-14-66f9ffa9fc68> in <module>()
      4 from collections import Counter
      5 import en_core_web_sm
----> 6 import en_ner_bc5cdr_md
      7 import en_core_sci_sm
      8 import en_core_sci_md

/usr/local/lib/python3.6/dist-packages/en_ner_bc5cdr_md/__init__.py in <module>()
      5 from spacy.util import load_model_from_init_py, get_model_meta
      6 
----> 7 from scispacy.custom_sentence_segmenter import combined_rule_sentence_segmenter
      8 
      9 __version__ = get_model_meta(Path(__file__).parent)['version']

ImportError: cannot import name 'combined_rule_sentence_segmenter'
python spacy
2个回答
0
投票

使用 en_core_sci_sm-0.2.5 而不是 en_core_sci_sm-0.2.0

!pip 安装 https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.2.5/en_core_sci_sm-0.2.5.tar.gz


0
投票

从这里下载最新模型 - https://allenai.github.io/scispacy/#:~:text=Model%20URL%3E-,Models,-Model

这对我有用,

pip install https://s3-us-west-2.amazonaws.com/ai2-s2-scispacy/releases/v0.5.4/en_core_sci_sm-0.5.4.tar.gz
© www.soinside.com 2019 - 2024. All rights reserved.