cat-aspect-extraction


Namecat-aspect-extraction JSON
Version 1.4.1 PyPI version JSON
download
home_page
SummaryAspect extraction based on word embeddings
upload_time2024-02-17 14:13:43
maintainer
docs_urlNone
author
requires_python
license
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', 0.8), ('service', 0.3), ('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": "",
    "name": "cat-aspect-extraction",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "cat,nlp,absa,topic modeling,sentiment analysis,aspect extraction,BERTopic,lda,top2vec,word2vec",
    "author": "",
    "author_email": "Marc-Alexis Aza\u00efs <azaismarc.pro@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/2d/d2/3214b9b435ef19305472dbdeb492be26039aca38b696c965c562bee4638c/cat-aspect-extraction-1.4.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', 0.8), ('service', 0.3), ('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": "",
    "summary": "Aspect extraction based on word embeddings",
    "version": "1.4.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": "23c7822bd5d619ae5ada1e912a751e0fb439423e15e9df03d6abe1f4769274e4",
                "md5": "5a77c62ccbc5cf604f55f2af811e6ef8",
                "sha256": "51310bdfdb44b54c8e21aa7a5b0227751097228695f2e996dc7e0d40048ff0fb"
            },
            "downloads": -1,
            "filename": "cat_aspect_extraction-1.4.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "5a77c62ccbc5cf604f55f2af811e6ef8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 17485,
            "upload_time": "2024-02-17T14:13:37",
            "upload_time_iso_8601": "2024-02-17T14:13:37.220266Z",
            "url": "https://files.pythonhosted.org/packages/23/c7/822bd5d619ae5ada1e912a751e0fb439423e15e9df03d6abe1f4769274e4/cat_aspect_extraction-1.4.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2dd23214b9b435ef19305472dbdeb492be26039aca38b696c965c562bee4638c",
                "md5": "7ee3d2613d98d9566eb0ada322bfaafb",
                "sha256": "9597e69c56373f391136e7ac4a313af19b89bbeb84adf61d9614742d1099a3cd"
            },
            "downloads": -1,
            "filename": "cat-aspect-extraction-1.4.1.tar.gz",
            "has_sig": false,
            "md5_digest": "7ee3d2613d98d9566eb0ada322bfaafb",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 16859,
            "upload_time": "2024-02-17T14:13:43",
            "upload_time_iso_8601": "2024-02-17T14:13:43.121430Z",
            "url": "https://files.pythonhosted.org/packages/2d/d2/3214b9b435ef19305472dbdeb492be26039aca38b696c965c562bee4638c/cat-aspect-extraction-1.4.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-02-17 14:13:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "azaismarc",
    "github_project": "cat-aspect-extraction",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "cat-aspect-extraction"
}
        
Elapsed time: 0.19563s