Coder Social home page Coder Social logo

text2emotion-library's Introduction

What is emotion?

Emotion is a biological state associated with the nervous system brought on by neurophysiological changes variously associated with thoughts, feelings, behavioural responses, and a degree of pleasure or displeasure. (Source: Wikipedia)

Human being can easily identify the emotions from text and experience it. But what about the machines, are they able to identify the emotions from text?

Text2Emotion is the python package which will help you to extract the emotions from the content.

  • Processes any textual message and recognize the emotions embedded in it.
  • Compatible with 5 different emotion categories as Happy, Angry, Sad, Surprise and Fear.

Features

1. Text Pre-processing

At first we have the major goal to perform data cleaning and make the content suitable for emotion analysis.

  • Remove the unwanted textual part from the message.
  • Perform the natural language processing techniques.
  • Bring out the well pre-processed text from the text pre-processing.

2. Emotion Investigation

Detect emotion from every word that we got from pre-processed text and take a count of it for further analytical process.

  • Find the appropriate words that express emotions or feelings.
  • Check the emotion category of each word.
  • Store the count of emotions relevant to the words found.
3. Emotion Analysis

After emotion investigation, there is the time of getting the significant output for the textual message we input earlier.

  • The output will be in the form of dictionary.
  • There will be keys as emotion categories and values as emotion score.
  • Higher the score of a particular emotion category, we can conclude that the message belongs to that category.

How to use?

App Deployment

Here's the code implementation with Streamlit App for the users.

  1. Enter the text.
  2. Hit the submit button.
  3. Tada!! Get the output in visual form.

Let's experience the library, test your multiple use cases on web app and check whether the library performs as per your expectations.

text2emotion-library's People

Contributors

aman2656 avatar amey23 avatar deepspacehub avatar karan2805 avatar shivamsharma26 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

text2emotion-library's Issues

Is there a way i can use this package in iOS Apps?

I want to install this package in Xcode.
Installation is successful using terminal in Mac, but not sure how can import this in Xcode?
Not sure its the right place to ask as its not an issue. Just want any hints?

Model misbehavior

In the demo Text2Emotion.ipynb file, for

text = "you got this man ๐Ÿ˜†๐Ÿ˜‚" 
the output was  
{'Angry': 0.0, 'Fear': 0.0, 'Happy': 1.0, 'Sad': 0.0, 'Surprise': 0.0}

but after I executed that file, I am getting output as 
{'Angry': 0, 'Fear': 0, 'Happy': 0, 'Sad': 0, 'Surprise': 0}

BEFORE
image

AFTER
image

Discrepancies with the web app/ weird emotions value

I first tested text2emotions with the online app, then I tried to use it in my Jupiter notebook. The results differ.

For instance the web app assigns no emotional value to "make", but the python package classifies it as "sad". To me, it doesn't make any sense. Similarly terms as "hope" and "horny" display different emotional values online and in jupyter. In the emotion dictionary used in the get_emotion function there are werid keys like "Rockfeller Center". The ones online are far more correct!

What version of the package is used by the online app? How can I reproduce those results? Are you sure the dictionary that defines emotional values is correct? Maybe something went wrong along the way! It is a great package but it is hard to use it like this!

module 'emoji' has no attribute 'UNICODE_EMOJI'

I'm using text2emoji, and it's working on my machine just fine. However, it's not working neither on google colab nor on docker containers. Here are that comes up when I run it:

  File "./main.py", line 44, in api_extract_emotion
    return extract_emotion(text)
  File "./functionalities/text2emotion.py", line 7, in extract_emotion
    return te.get_emotion(text)
  File "/usr/local/lib/python3.7/site-packages/text2emotion/__init__.py", line 2716, in get_emotion
    text = cleaning(input).split()
  File "/usr/local/lib/python3.7/site-packages/text2emotion/__init__.py", line 2700, in cleaning
    text = emojis_extractor(text)
  File "/usr/local/lib/python3.7/site-packages/text2emotion/__init__.py", line 2569, in emojis_extractor
    a = " ".join(c for c in text if c in emoji.UNICODE_EMOJI).split()
  File "/usr/local/lib/python3.7/site-packages/text2emotion/__init__.py", line 2569, in <genexpr>
    a = " ".join(c for c in text if c in emoji.UNICODE_EMOJI).split()
AttributeError: module 'emoji' has no attribute 'UNICODE_EMOJI'

The link for the Colab notebook is:
https://colab.research.google.com/drive/1sCAcIGk2q9dL8dpFYddnsUin2MlhjaRw?usp=sharing
the docker container is based on python:3.7-slim image
the installed packages on the docker container are

numpy==1.21.6
pandas==1.3.5
boto3==1.21.46
python-multipart==0.0.5
fastapi==0.75.0
uvicorn[standard]==0.17.6
torch==1.11.0
torchvision==0.12.0
torchaudio==0.11.0
gunicorn
transformers==4.11.3
text2emotion==0.0.5
nltk==3.7
google-cloud-language

=======================================
Now here are the settings of the working system:

OS: Manjaro Linux x86_64 
Kernel: 5.15.57-2-MANJARO 
Packages: 1676 (pacman), 6 (flatpak), 9 (snap) 
Shell: zsh 5.9 
DE: Plasma 5.24.6 
WM: KWin 
Theme: Breath Light [Plasma], Breeze [GTK2/3] 
Icons: [Plasma], breeze [GTK2/3] 
CPU: Intel i7-7500U (4) @ 3.500GHz 
GPU: AMD ATI Radeon R7 M260/M265 / M340/M360 / M 
GPU: Intel HD Graphics 620 
Memory: 7405MiB / 15899MiB 

and here is a list of all of the installed packages

absl-py==1.0.0
aiodns==3.0.0
aiohttp==3.8.1
aiohttp-cors==0.7.0
aiosignal==1.2.0
aiosmtpd==1.4.2
altair==4.2.0
analytics-python==1.2.9
anyio==3.5.0
appdirs @ file:///home/conda/feedstock_root/build_artifacts/appdirs_1603108395799/work
argon2-cffi==21.3.0
argon2-cffi-bindings==21.2.0
arrow @ file:///home/conda/feedstock_root/build_artifacts/arrow_1643313750486/work
asgiref==3.5.0
astor==0.8.1
astunparse==1.6.3
async-generator==1.10
async-timeout==4.0.2
asynctest==0.13.0
atpublic==3.0.1
attrs @ file:///home/conda/feedstock_root/build_artifacts/attrs_1640799537051/work
autoflake==1.4
Automat==20.2.0
autopep8 @ file:///home/conda/feedstock_root/build_artifacts/autopep8_1635267974115/work
Babel==2.9.1
backcall==0.2.0
backports.zoneinfo==0.2.1
bamboolib==1.30.1
base58==2.1.1
beautifulsoup4==4.9.3
binaryornot==0.4.4
bitstring==3.1.9
bleach==4.1.0
blessed==1.19.1
blinker==1.4
blis==0.7.8
boto3==1.21.46
botocore==1.24.46
Brotli==1.0.9
brotlipy @ file:///home/conda/feedstock_root/build_artifacts/brotlipy_1648854164153/work
cached-property==1.5.2
cachetools==5.0.0
catalogue==2.0.7
category-encoders==2.5.0
certifi==2022.6.15
cffi @ file:///home/conda/feedstock_root/build_artifacts/cffi_1636046052501/work
chardet @ file:///home/conda/feedstock_root/build_artifacts/chardet_1649184113124/work
charset-normalizer @ file:///home/conda/feedstock_root/build_artifacts/charset-normalizer_1644853463426/work
click==7.1.2
click-config-file==0.6.0
click-plugins==1.1.1
cloudpickle==2.0.0
cmdstanpy==0.9.68
colorama @ file:///home/conda/feedstock_root/build_artifacts/colorama_1602866480661/work
colorful==0.5.4
conda==4.13.0
conda-package-handling @ file:///home/conda/feedstock_root/build_artifacts/conda-package-handling_1649385049221/work
configobj==5.0.6
constantly==15.1.0
convertdate==2.4.0
cookiecutter @ file:///home/conda/feedstock_root/build_artifacts/cookiecutter_1643669229020/work
cryptography @ file:///tmp/build/80754af9/cryptography_1652083456434/work
cssselect==1.1.0
cycler @ file:///home/conda/feedstock_root/build_artifacts/cycler_1635519461629/work
cymem==2.0.6
Cython==0.29.30
dask==2022.2.0
data-cache==0.1.6
dataclasses @ file:///home/conda/feedstock_root/build_artifacts/dataclasses_1628958434797/work
debugpy==1.5.1
decorator==5.1.1
defusedxml==0.7.1
demoji==1.1.0
distlib @ file:///home/conda/feedstock_root/build_artifacts/distlib_1638990147493/work
distributed==2022.2.0
dnspython==2.2.1
email-validator==1.1.3
emoji==1.7.0
en-core-web-sm @ https://github.com/explosion/spacy-models/releases/download/en_core_web_sm-3.4.0/en_core_web_sm-3.4.0-py3-none-any.whl
entrypoints==0.4
ephem==4.1.3
et-xmlfile==1.1.0
farasapy==0.0.14
fastapi==0.75.0
filelock @ file:///home/conda/feedstock_root/build_artifacts/filelock_1652442797291/work
flatbuffers==2.0
fonttools @ file:///home/conda/feedstock_root/build_artifacts/fonttools_1651017735934/work
frozenlist==1.3.0
fsspec==2022.3.0
gast==0.5.3
gdown==4.5.1
gitdb==4.0.9
GitPython==3.1.27
google-api-core==2.7.2
google-auth==2.6.6
google-auth-oauthlib==0.4.6
google-cloud-language==2.4.3
google-pasta==0.2.0
googleapis-common-protos==1.56.0
googlesearch-python==1.1.0
googletrans==3.0.0
gpustat==1.0.0b1
grpcio==1.47.0
grpcio-status==1.47.0
h11==0.9.0
h2==3.2.0
h5py==3.6.0
HeapDict==1.0.1
hijri-converter==2.2.4
holidays==0.13
hpack==3.0.0
hstspreload==2021.12.1
htmlmin==0.1.12
httpcore==0.9.1
httptools==0.4.0
httpx==0.13.3
huggingface-hub @ file:///home/conda/feedstock_root/build_artifacts/huggingface_hub_1652353891722/work
humanize==4.2.3
hyperframe==5.2.0
hyperlink==21.0.0
idna==2.10
ImageHash @ file:///home/conda/feedstock_root/build_artifacts/imagehash_1626361020540/work
importlib-metadata @ file:///home/conda/feedstock_root/build_artifacts/importlib-metadata_1648728291958/work
importlib-resources==5.4.0
incremental==21.3.0
install==1.3.5
ipykernel==6.9.1
ipyslickgrid==0.0.3
ipython==7.32.0
ipython-genutils==0.2.0
ipywidgets==7.6.5
isort==5.10.1
itemadapter==0.5.0
itemloaders==1.0.4
jedi==0.18.1
Jinja2 @ file:///home/conda/feedstock_root/build_artifacts/jinja2_1651774399431/work
jinja2-time @ file:///home/conda/feedstock_root/build_artifacts/jinja2-time_1646750632133/work
jmespath==1.0.0
joblib @ file:///home/conda/feedstock_root/build_artifacts/joblib_1633637554808/work
json5==0.9.6
jsonschema==4.4.0
jupyter==1.0.0
jupyter-client==7.1.2
jupyter-console==6.4.3
jupyter-contrib-core==0.3.3
jupyter-contrib-nbextensions==0.5.1
jupyter-core==4.9.2
jupyter-highlight-selected-word==0.2.0
jupyter-latex-envs==1.4.6
jupyter-nbextensions-configurator==0.4.1
jupyter-server==1.13.5
jupyterlab==3.3.1
jupyterlab-pygments==0.1.2
jupyterlab-server==2.10.3
jupyterlab-widgets==1.0.2
jupyterthemes==0.20.0
keras==2.8.0
Keras-Preprocessing==1.1.2
kiwisolver @ file:///home/conda/feedstock_root/build_artifacts/kiwisolver_1648854392523/work
korean-lunar-calendar==0.2.1
langcodes==3.3.0
lesscpy==0.15.0
libclang==14.0.1
locket==0.2.1
LunarCalendar==0.0.9
lxml==4.8.0
Markdown==3.3.7
MarkupSafe @ file:///home/conda/feedstock_root/build_artifacts/markupsafe_1648737551960/work
matplotlib @ file:///home/conda/feedstock_root/build_artifacts/matplotlib-suite_1651609498426/work
matplotlib-inline==0.1.3
mdutils==1.0.0
missingno==0.5.1
mistune==0.8.4
mkl-fft==1.3.1
mkl-random==1.2.2
mkl-service==2.4.0
modin==0.12.1
modin-spreadsheet==0.1.2
mrmr-selection==0.2.5
msgpack==1.0.3
multidict==6.0.2
multimethod==1.8
munkres==1.1.4
murmurhash==1.0.7
mutagen==1.45.1
nbclassic==0.3.6
nbclient==0.5.12
nbconvert==6.4.2
nbformat==5.2.0
nest-asyncio==1.5.4
networkx==2.6.3
nlpaug==1.1.11
nltk==3.7
notebook==6.4.8
notebook-shim==0.1.0
numexpr==2.8.3
numpy==1.21.6
nvidia-ml-py3==7.352.0
oauthlib==3.2.0
opencensus==0.9.0
opencensus-context==0.1.2
openpyxl==3.0.10
opt-einsum==3.3.0
outcome==1.1.0
packaging @ file:///home/conda/feedstock_root/build_artifacts/packaging_1637239678211/work
pandas==1.3.5
pandas-bamboo==0.1.5
pandas-profiling @ file:///home/conda/feedstock_root/build_artifacts/pandas-profiling_1651488952086/work
pandocfilters==1.5.0
parsel==1.6.0
parso==0.8.3
partd==1.2.0
pathy==0.6.2
patsy @ file:///home/conda/feedstock_root/build_artifacts/patsy_1632667180946/work
pexpect==4.8.0
phik @ file:///home/conda/feedstock_root/build_artifacts/phik_1647910144007/work
pickleshare==0.7.5
Pillow @ file:///home/conda/feedstock_root/build_artifacts/pillow_1649817984594/work
pip-chill==1.0.1
plotly==4.14.3
plumbum==1.7.2
ply==3.11
poyo==0.5.0
ppscore==1.2.0
preshed==3.0.6
prometheus-client==0.13.1
prompt-toolkit==3.0.28
prophet==1.0.1
Protego==0.2.1
proto-plus==1.20.6
protobuf==3.20.1
psutil==5.9.0
ptyprocess==0.7.0
py-spy==0.3.11
pyarrow==7.0.0
pyasn1==0.4.8
pyasn1-modules==0.2.8
pycares==4.1.2
pycodestyle @ file:///home/conda/feedstock_root/build_artifacts/pycodestyle_1633982426610/work
pycosat @ file:///home/conda/feedstock_root/build_artifacts/pycosat_1649384814992/work
pycparser @ file:///home/conda/feedstock_root/build_artifacts/pycparser_1636257122734/work
pycryptodomex==3.14.1
pydantic @ file:///home/conda/feedstock_root/build_artifacts/pydantic_1649125970599/work
pydeck==0.7.1
PyDispatcher==2.0.5
pyflakes==2.4.0
Pygments==2.11.2
PyMeeus==0.5.11
Pympler==1.0.1
pyOpenSSL @ file:///home/conda/feedstock_root/build_artifacts/pyopenssl_1643496850550/work
pyparsing @ file:///home/conda/feedstock_root/build_artifacts/pyparsing_1652235407899/work
pyrsistent==0.18.1
PySocks @ file:///home/conda/feedstock_root/build_artifacts/pysocks_1648857264451/work
pystan==2.19.1.1
python-dateutil @ file:///home/conda/feedstock_root/build_artifacts/python-dateutil_1626286286081/work
python-dotenv==0.20.0
python-multipart==0.0.5
python-slugify @ file:///home/conda/feedstock_root/build_artifacts/python-slugify_1651150815876/work
pytz @ file:///home/conda/feedstock_root/build_artifacts/pytz_1647961439546/work
pytz-deprecation-shim==0.1.0.post0
PyWavelets @ file:///home/conda/feedstock_root/build_artifacts/pywavelets_1649616401885/work
PyYAML @ file:///home/conda/feedstock_root/build_artifacts/pyyaml_1648757092905/work
pyzmq==22.3.0
qtconsole==5.3.0
QtPy==2.0.1
queuelib==1.6.2
ray==1.12.0
regex @ file:///home/conda/feedstock_root/build_artifacts/regex_1650839925403/work
requests==2.28.1
requests-file==1.5.1
requests-oauthlib==1.3.1
retrying==1.3.3
rfc3986==1.5.0
rpyc==4.1.5
rsa==4.8
ruamel-yaml-conda @ file:///home/conda/feedstock_root/build_artifacts/ruamel_yaml_1636009153751/work
s3transfer==0.5.2
sacremoses @ file:///home/conda/feedstock_root/build_artifacts/sacremoses_1651557636210/work
scikit-learn==0.24.2
scipy @ file:///tmp/build/80754af9/scipy_1641536880743/work
Scrapy==2.6.1
scrapy-user-agents==0.1.1
seaborn @ file:///home/conda/feedstock_root/build_artifacts/seaborn-split_1629095986539/work
selenium==4.1.3
semver==2.13.0
Send2Trash==1.8.0
sentencepiece==0.1.96
service-identity==21.1.0
setuptools-git==1.2
singledispatch==3.7.0
six @ file:///home/conda/feedstock_root/build_artifacts/six_1620240208055/work
sklearn==0.0
smart-open==5.2.1
smmap==5.0.0
sniffio==1.2.0
sortedcontainers==2.4.0
soupsieve==2.3.2.post1
spacy==3.4.0
spacy-legacy==3.0.9
spacy-loggers==1.0.3
srsly==2.4.3
starlette==0.17.1
statsmodels @ file:///home/conda/feedstock_root/build_artifacts/statsmodels_1644535599043/work
streamlit==1.7.0
swifter==1.1.3
tables==3.7.0
tangled-up-in-unicode @ file:///home/conda/feedstock_root/build_artifacts/tangled-up-in-unicode_1632832610704/work
tblib==1.7.0
tensorboard==2.8.0
tensorboard-data-server==0.6.1
tensorboard-plugin-wit==1.8.1
tensorboardX==2.5.1
tensorflow==2.8.0
tensorflow-io-gcs-filesystem==0.25.0
termcolor==1.1.0
terminado==0.13.3
testpath==0.6.0
text-unidecode==1.3
text2emotion==0.0.5
tf-estimator-nightly==2.8.0.dev2021122109
thinc==8.1.0
threadpoolctl==3.1.0
tldextract==3.2.0
tokenizers @ file:///tmp/build/80754af9/tokenizers_1639593992616/work
toml @ file:///home/conda/feedstock_root/build_artifacts/toml_1604308577558/work
toolz==0.11.2
torch==1.11.0
torch-tb-profiler==0.4.0
torchaudio==0.11.0
torchvision==0.12.0
tornado==6.1
tqdm @ file:///home/conda/feedstock_root/build_artifacts/tqdm_1649051611147/work
traitlets==5.1.1
transformers==4.11.3
trio==0.20.0
trio-websocket==0.9.2
twarc==2.11.1
tweepy==4.10.0
Twisted==22.2.0
typer==0.4.2
typing_extensions==4.1.1
tzdata==2021.5
tzlocal==4.1
ua-parser==0.10.0
ujson==5.3.0
unicodedata2 @ file:///home/conda/feedstock_root/build_artifacts/unicodedata2_1649111917568/work
Unidecode @ file:///home/conda/feedstock_root/build_artifacts/unidecode_1646918762405/work
urllib3 @ file:///home/conda/feedstock_root/build_artifacts/urllib3_1647489083693/work
user-agents==2.2.0
uvicorn==0.17.6
uvloop==0.16.0
validators==0.18.2
verify-email==2.4.3
virtualenv @ file:///tmp/build/80754af9/virtualenv_1620977681940/work
visions @ file:///home/conda/feedstock_root/build_artifacts/visions_1632831254311/work
voila==0.3.2
w3lib==1.22.0
wasabi==0.9.1
watchdog==2.1.6
watchgod==0.8.2
wcwidth==0.2.5
webencodings==0.5.1
websocket-client==1.3.1
websockets==10.2
Werkzeug==2.1.2
widgetsnbextension==3.5.2
wikipedia==1.4.0
wrapt==1.14.1
wsproto==1.1.0
xlrd==2.0.1
yarl==1.7.2
yt-dlp==2022.3.8.2
zict==2.1.0
zipp @ file:///home/conda/feedstock_root/build_artifacts/zipp_1649012893348/work
zope.interface==5.4.0

I hope I find a solution for this quickly, as it's so urgent. Thanks in advance.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.