cat-aspect-extraction


Namecat-aspect-extraction JSON
Version 1.0.1 PyPI version JSON
download
home_pageNone
SummaryAspect extraction based on word embeddings
upload_time2024-05-21 12:56:57
maintainerNone
docs_urlNone
authorNone
requires_pythonNone
licenseNone
keywords cat nlp absa topic modeling sentiment analysis aspect extraction bertopic lda top2vec word2vec
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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/

![cat walking on a computer keyboard](https://raw.githubusercontent.com/azaismarc/cat-aspect-extraction/master/cat.gif)

## Installation

```bash
pip install cat-aspect-extraction
```

or

```bash
git clone
python -m pip install .
```

## Example

```python
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

cat.get_scores(sentence, attention=RBFAttention())
>>> [('food', 1), ('service', 0.5), ('ambiance', 0.0)]
```

## Citations

**I'm not the author of the original paper**, so if you use this library, please cite the original paper :

```bibtex
@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

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "cat-aspect-extraction",
    "maintainer": null,
    "docs_url": null,
    "requires_python": null,
    "maintainer_email": null,
    "keywords": "cat, nlp, absa, topic modeling, sentiment analysis, aspect extraction, BERTopic, lda, top2vec, word2vec",
    "author": null,
    "author_email": "Marc-Alexis Aza\u00efs <azaismarc.pro@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/4a/d3/7b85eeedf09d1c150a473c18c658dd9f94acac4845e35586bbdb6855632e/cat_aspect_extraction-1.0.1.tar.gz",
    "platform": null,
    "description": "# cat-aspect-extraction\ud83d\udc08\n\nEasy to use library for implement Contrastive Attention Topic Modeling describe in *Embarrassingly Simple Unsupervised Aspect Extraction*\n\n**Read the paper & the original repository for details about the algorithm !**\n\n- PAPER : https://aclanthology.org/2020.acl-main.290/\n- REPOSITORY : https://github.com/clips/cat/\n\n![cat walking on a computer keyboard](https://raw.githubusercontent.com/azaismarc/cat-aspect-extraction/master/cat.gif)\n\n## Installation\n\n```bash\npip install cat-aspect-extraction\n```\n\nor\n\n```bash\ngit clone\npython -m pip install .\n```\n\n## Example\n\n```python\nfrom cat_aspect_extraction import CAt, RBFAttention # for using the model\nfrom reach import Reach # for loading word embeddings\n\n# Load in-domain word embeddings and create a CAt instance\nr = Reach.load(\"path/to/embeddings\", unk_word=\"UNK\")\ncat = CAt(r)\n\n# Initialize candidate aspects\n\ncandidates = [\n    \"food\",\n    \"service\",\n    \"ambiance\",\n    \"price\",\n    \"location\",\n    \"experience\"\n]\n\nfor aspect in candidates:\n    cat.add_candidate(aspect)\n\n# Add topics\n\ncat.add_topic(\"food\", [\"taste\", \"flavor\", \"quality\", \"portion\", \"menu\", \"dish\", \"cuisine\", \"ingredient\"])\n\ncat.add_topic(\"service\", [\"staff\", \"waiter\", \"waitress\", \"service\", \"server\", \"host\", \"manager\", \"bartender\"])\n\ncat.add_topic(\"ambiance\", [\"atmosphere\", \"decor\", \"interior\", \"design\", \"lighting\", \"music\", \"noise\", \"vibe\"])\n\n# Compute topic score\n\nsentence = \"The food was great !\".split() # tokenize your sentence\n\ncat.get_scores(sentence, attention=RBFAttention())\n>>> [('food', 1), ('service', 0.5), ('ambiance', 0.0)]\n```\n\n## Citations\n\n**I'm not the author of the original paper**, so if you use this library, please cite the original paper :\n\n```bibtex\n@inproceedings{tulkens2020embarrassingly,\n    title = \"Embarrassingly Simple Unsupervised Aspect Extraction\",\n    author = \"Tulkens, St{\\'e}phan  and  van Cranenburgh, Andreas\",\n    booktitle = \"Proceedings of the 58th Annual Meeting of the Association for Computational Linguistics\",\n    month = jul,\n    year = \"2020\",\n    address = \"Online\",\n    publisher = \"Association for Computational Linguistics\",\n    url = \"https://www.aclweb.org/anthology/2020.acl-main.290\",\n    doi = \"10.18653/v1/2020.acl-main.290\",\n    pages = \"3182--3187\",\n}\n```\n\n## License\n\nGNU General Public License v3.0\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Aspect extraction based on word embeddings",
    "version": "1.0.1",
    "project_urls": {
        "Paper": "https://aclanthology.org/2020.acl-main.290/",
        "Repository": "https://github.com/azaismarc/cat-aspect-extraction.git",
        "Repository (original)": "https://github.com/clips/cat/"
    },
    "split_keywords": [
        "cat",
        " nlp",
        " absa",
        " topic modeling",
        " sentiment analysis",
        " aspect extraction",
        " bertopic",
        " lda",
        " top2vec",
        " word2vec"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "4ad37b85eeedf09d1c150a473c18c658dd9f94acac4845e35586bbdb6855632e",
                "md5": "58619ece8d1388acfd6836492f3c3612",
                "sha256": "1eafd5729ec2950327945cfee0f0540eaf460062084fd80532c7fcdd45b5f0a5"
            },
            "downloads": -1,
            "filename": "cat_aspect_extraction-1.0.1.tar.gz",
            "has_sig": false,
            "md5_digest": "58619ece8d1388acfd6836492f3c3612",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16906,
            "upload_time": "2024-05-21T12:56:57",
            "upload_time_iso_8601": "2024-05-21T12:56:57.759463Z",
            "url": "https://files.pythonhosted.org/packages/4a/d3/7b85eeedf09d1c150a473c18c658dd9f94acac4845e35586bbdb6855632e/cat_aspect_extraction-1.0.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-21 12:56:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "azaismarc",
    "github_project": "cat-aspect-extraction",
    "github_not_found": true,
    "lcname": "cat-aspect-extraction"
}
        
Elapsed time: 3.48152s