A wrapper around CountVectorizer which counts semantically similar tokens
Project description
Wrapper around CountVectorizer to count phrases based on semantic similarity
SemanticCountVectorizer extends CountVectorizer by counting the frequency of semantically similar tokens. This is useful when searching for frequency of similar but not exact terms.
SemanticCountVectorizer uses sentence_transformers to compute embedding of n-grams and then clusters similar terms using Agglomerative Clustering using cosine similarity as the similarity metric
Usage
from semantic_vectorizer import SemanticCountVectorizer
sentences = ['this is a test sentences','this is another test sentence']
svect = SemanticVectorizer(embedding_model_name='all-MiniLM-L6-v2', similarity_threshold=0.7, ngram_range=(3,3))
counts=svect.fit_transform(sentences)
Arguments
- embedding_model_name: Name of the sentence_transformer pretrained model to use. Refer to package website for a list of available models
- similarity_threshold: value between 0-1 which indicates minimum cosine similarity needed to group tokens.
- Arguments of sklearn's CountVectorizer as listed here
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file semantic_counter-0.0.2.tar.gz.
File metadata
- Download URL: semantic_counter-0.0.2.tar.gz
- Upload date:
- Size: 3.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
948028bab517a92fccaea81e2c827edd650ccc9de6617e0d4020bf5135de5c7d
|
|
| MD5 |
6d3e0114b265de7f1fdfefe2f9eb713c
|
|
| BLAKE2b-256 |
6e362e6388c89b922e0921ce61d181c3ef573558c0849d61862477f43f5c03f8
|
File details
Details for the file semantic_counter-0.0.2-py3-none-any.whl.
File metadata
- Download URL: semantic_counter-0.0.2-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8a4ba973f59f2fc4ba3b3b9821b495176d62a2931590256bf8044194b8f214c1
|
|
| MD5 |
0228b2cd98a818df54efc6872205e59a
|
|
| BLAKE2b-256 |
8f1f5cb23df573b2ca6714eb7dcebe1f41513d331128368f0e23292419621dcc
|