explosion / spaCy

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

DataCamp course exercise problems #4879

Closed guney1 closed 4 years ago

guney1 commented 4 years ago

Hi,

I am running datacamp exercises in my own system but I have some problems, datacamp uses 2.1.0 when I try to use this version in my system I get a bad escape error when loading the models, same thing happens when I use the latest version, problem disappears when I use version 2.0.16. Also when I use conda to install spacy, it auto. installs 2.0.16 rather than latest version.

My specific problem is when I do the following exercise in datacamp:

def get_wikipedia_url(span):

Get a Wikipedia URL if the span has one of the labels

if span.label_ in ('PERSON', 'ORG', 'GPE', 'LOCATION'):
    entity_text = span.text.replace(' ', '_')
    return "https://en.wikipedia.org/w/index.php?search=" + entity_text

Span.set_extension("wikipedia_url", getter=get_wikipedia_url, force=True)

doc = nlp("In over fifty years from his very first recordings right through to his last album, David Bowie was at the vanguard of contemporary culture.") for ent in doc.ents:

Print the text and Wikipedia URL of the entity

print(ent.text, ent._.wikipedia_url)

I get the named entities but when I run the same piece of code in my own system I get a empty tuple as output

My Environment

Thanks a lot

adrianeboyd commented 4 years ago

I think you do need spacy v2.1 to run these exercises. You can install it from conda-forge:

Set up for conda-forge:

conda config --add channels conda-forge
conda config --set channel_priority strict

Then install the right version of spacy for these exercises:

conda install spacy==2.1.3

Now you can run python -m spacy validate to see if the models need to be updated, too. If there's a red X next to one of the model entries, use python -m spacy download MODEL to automatically download the right version for the currently installed spacy version.

lock[bot] commented 4 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.