使用spacy加载英文模块时如何解决内存错误?

时间:2019-02-11 06:57:44

标签: python-3.x nlp spacy

我已经导入了spacy软件包来加载英语模块,如下所示:

    import spacy
    nlp = spacy.load('en_core_web_lg')
    text = "London is the most populous city of United Kingdom."
    # Parse the text with spaCy. This runs the entire pipeline.
    doc = nlp(text)

预期结果是在使用spacy加载英文模块时出现以下错误时,文档应包含文本的解析版本

Traceback (most recent call last):
  File "D:/Python/MachineLearning_NLP/First.py", line 5, in <module>
    nlp = spacy.load('en_core_web_lg')
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\__init__.py", line 21, in load
    return util.load_model(name, **overrides)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\util.py", line 114, in load_model
    return load_model_from_package(name, **overrides)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\util.py", line 135, in load_model_from_package
    return cls.load(**overrides)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\en_core_web_lg\__init__.py", line 12, in load
    return load_model_from_init_py(__file__, **overrides)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\util.py", line 173, in load_model_from_init_py
    return load_model_from_path(data_path, meta, **overrides)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\util.py", line 156, in load_model_from_path
    return nlp.from_disk(model_path)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\language.py", line 647, in from_disk
    util.from_disk(path, deserializers, exclude)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\util.py", line 511, in from_disk
    reader(path / key)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\language.py", line 635, in <lambda>
    self.vocab.from_disk(p) and _fix_pretrained_vectors_name(self))),
  File "vocab.pyx", line 380, in spacy.vocab.Vocab.from_disk
  File "vectors.pyx", line 391, in spacy.vectors.Vectors.from_disk
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\spacy\util.py", line 511, in from_disk
    reader(path / key)
  File "vectors.pyx", line 384, in spacy.vectors.Vectors.from_disk.load_vectors
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\numpy\lib\npyio.py", line 440, in load
    pickle_kwargs=pickle_kwargs)
  File "D:\Python\MachineLearning_NLP\venv\lib\site-packages\numpy\lib\format.py", line 704, in read_array
    array = numpy.fromfile(fp, dtype=dtype, count=count)
MemoryError

0 个答案:

没有答案