cat-aspect-extraction🐈
Easy to use library for implement Contrastive Attention Topic Modeling describe in Embarrassingly Simple Unsupervised Aspect Extraction
Read the paper & the original repository for details about the algorithm !
- PAPER : https://aclanthology.org/2020.acl-main.290/
- REPOSITORY : https://github.com/clips/cat/
Installation
pip install cat-aspect-extraction
or
git clone
python -m pip install .
Example
from cat_aspect_extraction import CAt, RBFAttention # for using the model
from reach import Reach # for loading word embeddings
# Load in-domain word embeddings and create a CAt instance
r = Reach.load("path/to/embeddings", unk_word="UNK")
cat = CAt(r)
# Initialize candidate aspects
candidates = [
"food",
"service",
"ambiance",
"price",
"location",
"experience"
]
for aspect in candidates:
cat.add_candidate(aspect)
# Add topics
cat.add_topic("food", ["taste", "flavor", "quality", "portion", "menu", "dish", "cuisine", "ingredient"])
cat.add_topic("service", ["staff", "waiter", "waitress", "service", "server", "host", "manager", "bartender"])
cat.add_topic("ambiance", ["atmosphere", "decor", "interior", "design", "lighting", "music", "noise", "vibe"])
# Compute topic score
sentence = "The food was great !".split() # tokenize your sentence
att = RBFAttention() # Using attention
cat.get_scores(sentence, attention=att)
>>> [('food', 1), ('service', 0.5), ('ambiance', 0.0)] # Score are scaled by RobustScaler followed by MinMaxScaler
Citations
I'm not the author of the original paper, so if you use this library, please cite the original paper :
@inproceedings{tulkens2020embarrassingly,
title = "Embarrassingly Simple Unsupervised Aspect Extraction",
author = "Tulkens, St{\'e}phan and van Cranenburgh, Andreas",
booktitle = "Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics",
month = jul,
year = "2020",
address = "Online",
publisher = "Association for Computational Linguistics",
url = "https://www.aclweb.org/anthology/2020.acl-main.290",
doi = "10.18653/v1/2020.acl-main.290",
pages = "3182--3187",
}
License
GNU General Public License v3.0
Metadata
Release files for cat-aspect-extraction 2.0.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 | |
|---|---|---|---|
| cat_aspect_extraction-2.0.1.tar.gz | 17.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cat_aspect_extraction-2.0.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 34.8 kB
Release files / cat_aspect_extraction-2.0.1.tar.gz
| Download URL | cat_aspect_extraction-2.0.1.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ea7bc693b0cd6fcca2261ba7b4aa54110d583896197e272973d6ec7b7f1b1dcf
|
|
BLAKE2b-256 checksum How to use checksums |
490c2b3f4811802b635064fd4605ebb0eaec2160363215fac2bd421abf09425b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / cat_aspect_extraction-2.0.1-py3-none-any.whl
| Download URL | cat_aspect_extraction-2.0.1-py3-none-any.whl |
|---|---|
| Size | 17.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b5aa72d24739a303cd5571b5ee5bfe8129678dea7f245afc4bc70d0e816c26d5
|
|
BLAKE2b-256 checksum How to use checksums |
e7939f756af68cac499352278fc35d03f974ea5a5023c4eca6980cbd7cc1feca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|