Skip to main content

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

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.4.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

marlo_sentiment-1.0.4-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

Details for the file marlo_sentiment-1.0.4.tar.gz.

File metadata

  • Download URL: marlo_sentiment-1.0.4.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

Hashes for marlo_sentiment-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f936be1ef11b8ce538024e7addb30f7c21a6ca7b6a3ceb28dcee2287c7daf5e4
MD5 176366b0ff90c5d6ae66828ed624393c
BLAKE2b-256 73809a33d7fb54a78a29ef1d1d57cdf7f3954c1fb04d6e7ab4be434389b7c036

See more details on using hashes here.

File details

Details for the file marlo_sentiment-1.0.4-py3-none-any.whl.

File metadata

File hashes

Hashes for marlo_sentiment-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 119c21cb9221b388f37f788c434294dce5dab7afa56287c922d1de7ecf47d69f
MD5 574e61a550f65b0ba91fa762599abc7d
BLAKE2b-256 8cf1da4c840c53e41b29d751b5ea248bcb7c1436fcb2a2ae3137e6198e564dee

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page