A Python library that counts letter frequency using OpenAI API
Project description
vibecount
A Python library that counts the frequency of letters in a string using OpenAI API.
Features
- Count frequency of specific letters in text
- Case-sensitive and case-insensitive counting options
- Uses OpenAI API for intelligent letter counting
- Easy to use API
- Ready for PyPI distribution
Installation
Install the package using pip:
pip install vibecount
Setup
You need to provide your own OpenAI API key. Set it as an environment variable:
export OPENAI_API_KEY=your_openai_api_key_here
Usage
Basic Usage
from vibecount import vibecount
# Count letter 'r' in "strawberry" (case-sensitive by default)
result = vibecount("strawberry", "r")
print(result) # 3
# Case-insensitive counting
result = vibecount("Strawberry", "R", case_sensitive=False)
print(result) # 3
# Case-sensitive counting (explicit)
result = vibecount("Strawberry", "R", case_sensitive=True)
print(result) # 0 (no uppercase 'R' in "Strawberry")
Parameters
text(str): The input string to analyzetarget_letter(str): The letter to count (must be a single character)case_sensitive(bool, optional): Whether to perform case-sensitive counting (default: True)
Return Value
Returns an integer representing the count of the target letter in the text.
Error Handling
The function raises:
ValueError: If OpenAI API key is not set or target_letter is not a single characterException: If OpenAI API call fails
Requirements
- Python 3.8+
- OpenAI API key
- Internet connection for API calls
Dependencies
openai>=1.0.0
Development
Running Tests
Install test dependencies:
pip install -r test-requirements.txt
Run tests:
pytest
Run tests with coverage:
pytest --cov=vibecount
Run specific test file:
pytest tests/test_vibecount.py
Test Structure
The test suite includes:
- Unit tests for all function parameters and edge cases
- Mock tests for OpenAI API calls (no actual API calls during testing)
- Error handling validation
- Input validation tests
License
This project is licensed under the MIT License - see the LICENSE file for details.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Note
This package uses the OpenAI API for letter counting, which requires an API key and internet connection. Each function call will make a request to OpenAI's servers and will consume API credits.
Project details
Release history Release notifications | RSS feed
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 vibeutils-0.1.0.tar.gz.
File metadata
- Download URL: vibeutils-0.1.0.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
057ba0ac0b7261d8fa0fe5cddb0be657878abd1ff01f7e1af4981699392e6bf4
|
|
| MD5 |
66b2b21a334a0788d76249b20364bbd3
|
|
| BLAKE2b-256 |
d3ab3ad8757fd955a277380dc13709cebe2be262213fcecd21644602f8e44a17
|
File details
Details for the file vibeutils-0.1.0-py3-none-any.whl.
File metadata
- Download URL: vibeutils-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
da41a425600e38a803861f3b072f03c89d1add362d6c055db1a98fcba9338165
|
|
| MD5 |
4001da734945f41920ea0062a1bfd544
|
|
| BLAKE2b-256 |
f5ab972703ccfb37e0add85555ff8b04433f51caf6f6a1126b1636b2bd94b5c7
|