Short-text-analyzer
This ShortTextAnalyzer was created to help analyze the open-ended survey response which usually has less than three sentences. The analysis includes topic modeling, sentiment analysis, and visualization. This topic modeling was done using pre-trained representations of language, namely BERT, combine with the clustering algorithm.
Documentation Page: https://thisisphume.github.io/short-text-analyzer/
Install
pip install short-text-analyzer
Install all the required packages from the requirement.txt file.
pip install -r requirements.txt
from shorttextanalyzer.core import *
How to use
analyzer = shortTextAnalyzer(comments_series, 4)
output_result = analyzer.analyze_getResult()
Embedding Method for Visualization is 2AE with MSE of 0.6560611658549391
Embedding Method for Clustering is 2AE with MSE of 0.4782262679093038
Number of clusters via HDBSCAN is: 5.0
Number of clusters via KMeans is: 4
Here we specify that we want 4 clusters/topic from this data.
Output: result
sentimentScore: Polarity score ranges from [-1,1] where 1 means positive statement and -1 means a negative statement.Subjective: score ranges from [0,1] where 1 refer to personal opinion, emotion or judgment and 0 means it is factual information.clusterByKMeans: assigned cluster number for each comments using KMeansclusterByHDBSCAN: assigned cluster number for each comments using HDBSCAN
output_result.sample(2)
| comments | comment_lang | comments_clean | sentimentScore | subjectiveScore | clusterByKMeans | clusterByHDBSCAN | |
|---|---|---|---|---|---|---|---|
| 50 | sondage parfait | fr | perfect poll | 1.00 | 1.000000 | 2 | 1 |
| 875 | it wasn't very clear what the purpose of the f... | en | it wasn't very clear what the purpose of the f... | 0.19 | 0.415833 | 1 | 1 |
Visualization: how good is our clusters? HDBSCAN and KMeans
analyzer.plot_output()
Reference
- tBERT: Topic Models and BERT Joining Forces for Semantic Similarity Detection
- Using UMAP for clustering: https://umap-learn.readthedocs.io/en/latest/clustering.html#traditional-clustering
- https://github.com/dmmiller612/bert-extractive-summarizer
- https://github.com/MilaNLProc/contextualized-topic-models
- https://github.com/MaartenGr/BERTopic
- Natural Language Processing for Beginners: Using TextBlob
Release files for shorttextanalyzer 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| shorttextanalyzer-0.1.1.tar.gz | 14.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| shorttextanalyzer-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 30.1 kB
Release files / shorttextanalyzer-0.1.1.tar.gz
| Download URL | shorttextanalyzer-0.1.1.tar.gz |
|---|---|
| Size | 14.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4a1dc4d13b42e3607ce8b376e4c4238b5bcb8d9206173bde00c6070989967aac
|
|
BLAKE2b-256 checksum How to use checksums |
06f644565ab50528791895ac1ce1f72c0a89409fd962d3b50396591042f90962
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|
Release files / shorttextanalyzer-0.1.1-py3-none-any.whl
| Download URL | shorttextanalyzer-0.1.1-py3-none-any.whl |
|---|---|
| Size | 15.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2def863f10eccf7b9927f2f9ee8d9ace0ac6cd2197895dedef6bdeda35eaec8
|
|
BLAKE2b-256 checksum How to use checksums |
eadc0194ae5d5c88e8659fc05d19e4ddea924ba3c2a715297f4b6861319a2a98
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.1.post20201107 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.5
|