SangeethaVenkatesan / dash-example-index-apps

0 stars 0 forks source link

text-area-tool-tip app #1

Open Coding-with-Adam opened 2 years ago

Coding-with-Adam commented 2 years ago

Hi @SangeethaVenkatesan , I like the tooltip app. Just a few things to go over.

  1. Do you know how big the spacy library is? We would need to add that to the Dash-Example-Index requirements file.
  2. At first - after installing spacy - I got an error saying "Can't find model 'en_core_web_sm'. The only way I could fix that was with this installation: python -m spacy download en_core_web_sm. Did you encounter the same issue?
  3. Can you please add a comment right above the display.render(...) line of code, explaining to the user what this does.
  4. Can you please also add these two comments somewhere in the code, for those people who don't know what nlp entities are. This is a good opportunity to educate new Dash community members.
    # A named entity is a “real-world object” that’s assigned a name – for example, a person, a country, a product or a book title.
    # spaCy can recognize various types of named entities in a document, by asking the model for a prediction.
  5. Once we're done with the app modifications in this repo, feel free to do a PR in the app-gallery repo. AnnMarie will take one final look at it to ensure all is ok, including the dangerously_allow_html=True

I really like this app, it's amazing how much one can do with NLP with very few lines of code. Thank you,

SangeethaVenkatesan commented 2 years ago

Hello @Coding-with-Adam That's very nice feedback!

1) https://github.com/explosion/spacy-models#downloading-models Around 50 MB for the small model - "en_core_web_sm" 2) Yes Adam, `# download best-matching version of specific model for your spaCy installation python -m spacy download en_core_web_sm

pip install .whl or .tar.gz archive from path or URL

pip install /Users/you/en_core_web_sm-3.0.0.tar.gz pip install /Users/you/en_core_web_sm-3.0.0-py3-none-any.whl pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0.tar.gz pip install https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.0.0/en_core_web_sm-3.0.0-py3-none-any.whl` Above is the procedure to install the package before importing

3) Sure Adam, I will add. It creates a markdown HTML, that renders the entity name and label as in given in spacy package. I will add explanation

4) Thats true - I will for sure, make a small note about Named Enitity Recognition

Thanks a lot Adam, WIll make these changes and do a PR. For now given in dash doc, this is the property that renders the external HTML markdown. Streamlit also does the same attribute to have displacy rendered in the application.

Coding-with-Adam commented 2 years ago

hi @SangeethaVenkatesan I was talking to one of our engineers. It looks like we should be able to use the en_core_web_sm. We would need to do the following:

  1. add spacy to the requirements.txt file of the example-index repo.
  2. add the following lines of code to the app, right under from spacy import displacy:
    import os
    os.system("python -m spacy download en_core_web_sm")

    This should work, as it would install the model into memory and allow users to run the app. I tried it locally and it worked.

Feel free to make these and the changes you mentioned, then let's add it through a PR in the main example-index repo.