Report this

What is the reason for this report?

How do I load locally stored tweets instead of using from nltk.corpus import twitter_samples.

Posted on August 6, 2020

Every example I have seen on the internet about sentiment analysis uses a pre-existing sample file imported from nltk.corpus but I already have multiple .db files for training. How would I use those and not import from nltk.corpus? Anyone?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.

To perform sentiment analysis with your own .db files, you would need to replace the data loaded from the nltk.corpus with your own data.

Typically, this involves three steps:

  1. Load the data from your .db files.

  2. Preprocess your data to the same structure as that which is expected by the sentiment analysis model.

  3. Feed the preprocessed data into the model in lieu of the nltk.corpus data.

While the specifics can vary based on your .db file structure and the sentiment analysis model you are using, this general process should guide you in the right direction.

Please refer to DigitalOcean Tutorials for in-depth guides on Python and Data Science topics.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.