polars_countvectorizer
polars_countvectorizer is a Rust-based Python library that provides text vectorization and cosine distance calculation, optimized for use with Polars DataFrames. The library offers a function to compute the cosine distance between two text columns in a Polars DataFrame, making it useful for text similarity and document analysis tasks.
Features
- Cosine Distance Calculation: Computes the cosine similarity between two text columns in a Polars DataFrame.
- CountVectorizer Integration: Uses the CountVectorizer from the linfa_preprocessing crate to vectorize text data.
- Optimized for Performance: Leverages parallel processing via rayon for faster computations.
Installation
To install the package, you will need to have Python and Rust installed. Then, use pip to install the Python bindings:
pip install polars_countvectorizer Alternatively, if you're developing locally, you can build the package using maturin:
First, ensure maturin is installed: pip install maturin Then, run the following command to build and install the package:
maturin develop
Usage
import polars as pl
import polars_countvectorizer
df = pl.DataFrame({
"doc1": ["apple orange banana", "dog cat mouse", "car bike bus"],
"doc2": ["apple banana", "cat dog", "bus car bike"]
})
result = df.select(
polars_countvectorizer.process_cosine_distances_py("doc1", "doc2")
)
print(result)
Metadata
Release files for polars-countvectorizer 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| polars_countvectorizer-0.1.0-cp311-cp311-macosx_11_0_arm64.whl | CPython 3.11 | CPython 3.11 | macOS 11.0+ ARM64 | Details for polars_countvectorizer-0.1.0-cp311-cp311-macosx_11_0_arm64.whl |
Release files / polars_countvectorizer-0.1.0-cp311-cp311-macosx_11_0_arm64.whl
| Download URL | polars_countvectorizer-0.1.0-cp311-cp311-macosx_11_0_arm64.whl |
|---|---|
| Size | 10.6 MB |
| Tags | CPython 3.11 macOS 11.0+ ARM64 |
|
SHA-256 checksum How to use checksums |
b2ee0369984bb6362e24b486115a8b3f53e727b8e611ee7725d3842b3f5aac29
|
|
BLAKE2b-256 checksum How to use checksums |
c272afb38cd3d0d60b33eb2c11e81ea940da891112306794bdb018d5e4dd7900
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Security for polars-countvectorizer 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.