explosion / spaCy

💫 Industrial-strength Natural Language Processing (NLP) in Python
https://spacy.io
MIT License
30.21k stars 4.4k forks source link

ValueError: noun_chunks requires the dependency parse, which requires a statistical model to be installed and loaded. #1691

Closed hoyeunglee closed 6 years ago

hoyeunglee commented 6 years ago

https://gist.github.com/hoyeunglee/0cb3aa44a1d2e70c2f12e30200b82430

i use nlp variable after trained and think , no need to load

got error when create a csv format

print("ip,ip") ip,ip for bb in content[101:200]: ... mm = parse_sentence(bb.decode('utf-8')) ... if mm["parse_list"]: ... if mm["parse_list"][0]["IPADDRESS"]: ... print("test1") ... print(mm["parse_list"][0]["IPADDRESS"]+","+mm["parse_list"][0]["IPADDRESS"]) ... else: ... print("","") ... Traceback (most recent call last): File "", line 2, in File "", line 10, in parse_sentence File "doc.pyx", line 478, in get ValueError: noun_chunks requires the dependency parse, which requires a statistical model to be installed and loaded. For more info, see the documentation: https://spacy.io/usage/models

print("ip,ip")
for bb in content[101:200]:
    mm = parse_sentence(bb.decode('utf-8'))
    if mm["parse_list"]:
        if mm["parse_list"][0]["IPADDRESS"]:
            print("test1")
            print(mm["parse_list"][0]["IPADDRESS"]+","+mm["parse_list"][0]["IPADDRESS"])
    else:
        print("","")
ines commented 6 years ago

Sorry for only getting to this now. Your code example is a bit long and not easy to follow – but from how I see it, you're starting off with a blank model (nlp = spacy.blank('en')) and then updating it with NER annotations. This means the model will be able to predict entities – but not the dependency parse, since it has no parser. That's likely why you're seeing the error above. If you start off with an existing model like en_core_web_sm and are only disabling the other components during training (e.g. using nlp.disable_pipes), the model will have a parser, and the noun chunks should work as expected.

lock[bot] commented 6 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.