alfonsosemeraro / pyplutchik

Python visualisation for Plutchik annotated corpora.
65 stars 12 forks source link

How to use pyplutchik? #1

Closed csantanaes closed 2 years ago

csantanaes commented 3 years ago

How to use pyplutchik in the dataframe using pandas for analysis data from twitter?

Cleyton

alfonsosemeraro commented 3 years ago

Hello Cleyton,

thank you for your interest in PyPlutchik. The library can currently only display the emotions you find in your tweets in the flower-shaped representation, but you still need to extract the emotions from the tweets with some other tool. As of now, PyPlutchik is only a visualization tool.

We are working on a new release of PyPlutchik, that will allow users to extract emotions directly from texts (also tweets) and visualize them. Integration with pandas will be easy. We should release it in 6 weeks, hopefully. Stay tuned!

csantanaes commented 3 years ago

Dear Alfonso, thank you for the prompt return. I will wait for news about the integration with pandas to continue my research. The tool idea is excellent. I have been working with social media and the solution will allow you to analyze and visualize feelings on social media.

Today, is it possible to perform the visual of a textual corpus? I liked the documentation provided. I missed an example of how to apply the solution in a corpus for display along with matplotlib.

Overall, I wish success in the development of the tool. I read the article PYPLUTCHIK: VISUALISING AND COMPARING EMOTION-ANNOTATED CORPORA∗ and I was very excited about the possibility of using the package in my research here in Brazil.

BradKML commented 3 years ago

@alfonsosemeraro shout-out on:

alfonsosemeraro commented 3 years ago

Thank you @BrandonKMLee, if you have any more references please keep posting them, it's very helpful.

sm9449 commented 2 years ago

Hi, Love the potential applications of this visualization module but I get the following error on Python 3.8: ShapelyDeprecationWarning: The array interface is deprecated and will no longer work in Shapely 2.0. Convert the '.coords' to a numpy array instead.

Please help me resolve this, happens when I used this:

short_emotions = { 'joy': 0.23, 'trust': 0.07, 'fear': 0.09, 'surprise': 0.16, 'sadness': 0.13, 'disgust': 0.07, 'anger': 0.15, 'anticipation': 0.17 }

fig, ax = plt.subplots( nrows = 1, ncols = 2, figsize = (17, 8) )

plutchik(short_emotions, ax = ax[0]) plutchik(short_emotions, ax = ax[1], normalize = 0.25)

alfonsosemeraro commented 2 years ago

Hi @sm9449, thank you for your kind words. I'm sorry for the late reply.

It seems you have here a deprecation warning - which I'll take care of as soon as I can. However, it looks like you're facing an error that you didn't report. I tried to open a virtualenv with your Python version (3.8) and the latest version of the packages required by PyPlutchik, and I tried to reproduce your code. I got an error:

TypeError: annotate() missing 1 required positional argument: 'text'

This is due to matplotlib that changed the interface for matplotlib.pyplot.annotate(s, xy, *args, kwargs), that is now matplotlib.pyplot.annotate(text*, xy, args, **kwargs). I'll take care of this in the next days and I will update PyPlutchik accordingly.

Is this the error you found?

csantanaes commented 2 years ago

@alfonsosemeraro The bug was reported by @sm9449 .

alfonsosemeraro commented 2 years ago

@alfonsosemeraro The bug was reported by @sm9449 . Sorry, fixed.

csantanaes commented 2 years ago

I'll take care of this in the next days and I will update PyPlutchik accordingly.

What's new in the new update?

alfonsosemeraro commented 2 years ago

@csantanaes, if @sm9449 will confirm that the issue is with plt.annotate(), then I'll fix it.

With a lot of stop and go, we are working at the tool I was talking about some months ago. Please check https://github.com/alfonsosemeraro/emolib The repository hosts a very preliminary version of a tool for extracting emotions from raw texts. Chech test_Alf.ipynb for a quick go-through.