pythonspacy

cannot import name 'combined_rule_sentence_segmenter'


I have installed all the packages. while importing them am getting an error like "cannot import name 'combined_rule_sentence_segmenter'". How to import packages properly.

!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'

Solution

  • use en_core_sci_sm-0.2.5 instead of en_core_sci_sm-0.2.0

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