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.3.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.3-py3-none-any.whl (6.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: marlo_sentiment-1.0.3.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.3.tar.gz
Algorithm Hash digest
SHA256 5c07c128a73a8791b533b0b5e286da4356f430fe8eda7fed6a2cef78a718098d
MD5 823b432481181defafbc79efd69f6f50
BLAKE2b-256 8fdb6f7b9ea0cc37c2041be09e4192c91a331fc73dca34e8f6bae958bb9a9bc7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for marlo_sentiment-1.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 328b242b846460bb44491cc8eff740eb426bbe553495c764e460a300ab74e49b
MD5 fcebebcd1e90b14c75b8d10d2a00879f
BLAKE2b-256 a4d4e0f371d39ae68e77c1d66285488a0f92bd1d0c4073f127dbf26336b15f9c

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