Python client for Marlo sentiment analysis API
Project description
marlo-sentiment
Python client for the Marlo sentiment analysis API with industry-specific intelligence.
Installation
pip install marlo-sentiment
Usage
Basic Usage
from marlo_sentiment import MarloClient
client = MarloClient(api_key='your-rapidapi-key')
# Analyze text sentiment
result = client.analyze('I love this product!')
print(result)
# {
# 'sentiment': 'positive',
# 'confidence': 0.9162,
# 'scores': {
# 'positive': 0.647,
# 'neutral': 0.353,
# 'negative': 0.0,
# 'compound': 0.9162
# },
# 'text_length': 20
# }
Industry-Specific Analysis
# Healthcare context
healthcare_result = client.analyze(
'Strong medication led to successful treatment',
industry='healthcare'
)
# Gaming context
gaming_result = client.analyze(
'Epic gameplay but pay-to-win ruins it',
industry='gaming'
)
# Technology context
tech_result = client.analyze(
'Memory leak in the application',
industry='technology'
)
Batch Analysis
texts = [
'Great customer service!',
'Product arrived damaged',
'Fast shipping, excellent quality'
]
results = client.batch_analyze(texts, industry='retail')
Supported Industries
industries = client.get_supported_industries()
print(industries)
# ['healthcare', 'technology', 'gaming', 'finance', 'restaurant',
# 'automotive', 'real_estate', 'fitness', 'education', 'retail']
Configuration
Using Configuration Dict
from marlo_sentiment import MarloClient
client = MarloClient({
'api_key': 'your-rapidapi-key',
'base_url': 'https://custom-endpoint.com', # optional
'timeout': 5.0 # optional, default 10.0 seconds
})
Using API Key String
client = MarloClient('your-rapidapi-key')
Error Handling
from marlo_sentiment import MarloClient, MarloError, MarloValidationError
try:
result = client.analyze('')
except MarloValidationError as e:
print(f"Validation error: {e}")
except MarloError as e:
print(f"API error {e.status_code}: {e.message}")
Context Manager Support
with MarloClient('your-api-key') as client:
result = client.analyze('Great service!')
print(result.sentiment)
Type Hints
Full type hint support:
from marlo_sentiment import MarloClient, SentimentResponse, Industry
client = MarloClient('your-key')
result: SentimentResponse = client.analyze('text', industry='healthcare')
Requirements
- Python 3.8+
- requests >= 2.28.0
Development
Install Development Dependencies
pip install -e ".[dev]"
Run Tests
pytest
Code Formatting
black src/
isort src/
Type Checking
mypy src/
Resources
- Marlo API Documentation - Complete API guide and examples
- PyPI Package - Install via pip
- GitHub Repository - Source code and issues
- Support - Get help and contact support
License
MIT
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
marlo_sentiment-1.0.1.tar.gz
(5.7 kB
view details)
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 marlo_sentiment-1.0.1.tar.gz.
File metadata
- Download URL: marlo_sentiment-1.0.1.tar.gz
- Upload date:
- Size: 5.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bceaa73625e65345128b147f7d710f19385ba4f5bdcbeb847e0df156cf09004
|
|
| MD5 |
d984013b3c0469ee747828375602925b
|
|
| BLAKE2b-256 |
3d24d0736abce34373bfead583205c51000ecb5951974de68f0c641b5d1f4681
|
File details
Details for the file marlo_sentiment-1.0.1-py3-none-any.whl.
File metadata
- Download URL: marlo_sentiment-1.0.1-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cc13d3514d8572281ffae30eff24cb69009e527b93e327fa76cfceae2e9eb1e6
|
|
| MD5 |
4f71e1843a83d0e6ff92ec6de2476db3
|
|
| BLAKE2b-256 |
a2a4cff7ac3e1d367740a4e96980d58e788a0bbbbe378961896129909d020592
|