Skip to main content

Production-grade NLP library for unified content intelligence.

Project description

contentintelpy

Production-grade NLP library for unified content intelligence.

contentintelpy provides a unified, DAG-based engine for multilingual sentiment analysis, NER, translation, and summarization using real transformer models (RoBERTa, GLiNER, NLLB).

Features

  • Real Models: No heuristics. Uses State-of-the-Art Transformers.
    • Sentiment: RoBERTa
    • NER: GLiNER
    • Translation: NLLB (GPU) + ArgosTranslate (Offline CPU)
  • Hybrid Execution: Models download on first run (lazy-loaded). Offline fallback available.
  • Deterministic Pipelines: DAG-based execution guarantees order.
  • Dual API:
    • Pipeline-first for complex workflows.
    • Service-first for quick scripts.
  • Production Ready: Thread-safe, standard error handling, sparse outputs.

Installation

pip install contentintelpy

This single command installs everything — torch, transformers, spaCy + its English model, GLiNER, translation, sentiment, keywords, and geocoding.

[!TIP] GPU Support: If you have an NVIDIA GPU, install torch with CUDA support before running the above for faster inference:

pip install torch --index-url https://download.pytorch.org/whl/cu118
pip install contentintelpy

Quick Start

Ideal for simple tasks in notebooks or scripts.

from contentintelpy import SentimentService, TranslationService

# Sentiment
service = SentimentService()
result = service.analyze("This library is amazing!")
print(result) 
# {'value': 'positive', 'confidence': 0.99, ...}

# Translation
translator = TranslationService()
text = translator.translate("Hola mundo", target="en")
print(text)
# "Hello world"

Production Usage (Pipeline-First)

Recommended for Backends, APIs, and Data Pipelines.

import contentintelpy as ci

# 1. Create the canonical pipeline
pipeline = ci.create_default_pipeline()

# 2. Run it (Thread-safe)
result = pipeline.run({
    "text": "गूगल ने बेंगलुरु में नया कार्यालय खोला"
})

# 3. Access Sparse Output
print(result)

Output Example:

{
  "text": "...",
  "text_translated": "Google opened a new office in Bengaluru",
  "language": "hi",
  "entities": [
    {"text": "Google", "label": "ORG"},
    {"text": "Bengaluru", "label": "LOC"}
  ],
  "sentiment": {
    "value": "neutral",
    "value_en": "neutral",
    "confidence": 0.95
  },
  "summary": "..."
}

Advanced Usage: Custom Pipelines

You are not limited to the default pipeline. You can mix and match specific nodes to create a leaner, faster pipeline tailored to your needs.

1. Build a Custom Pipeline

Import individual nodes and pass them to the Pipeline constructor. The order matters!

from contentintelpy import Pipeline, LanguageDetectionNode, SentimentNode

# A lightweight pipeline that only does Language Detection + Sentiment
# Note: Sentiment often requires translation first if content isn't English, 
# but here we assume English input for speed.
custom_pipeline = Pipeline([
    LanguageDetectionNode(),
    SentimentNode()
])

result = custom_pipeline.run({
    "text": "This is a custom workflow!"
})
print(result)

2. Create Your Own Nodes

You can easily extend the library by creating your own nodes. Inherit from Node and implement process().

from contentintelpy import Node

class ProfanityCheckNode(Node):
    def __init__(self):
        super().__init__("ProfanityCheckNode")
    
    def process(self, context):
        text = context.get("text", "").lower()
        if "badword" in text:
            context.add_error("ProfanityCheckNode", "Content flagged as unsafe.")
        return context

# Add it to a pipeline
pipeline = Pipeline([
    ProfanityCheckNode(),
    SentimentNode()
])

Error Handling

Nodes never crash the pipeline. Errors are collected in errors dict.

{
    "text": "...",
    "errors": {
        "TranslationNode": "Model download failed: Connection error"
    }
}

Architecture

This library is pure logic. It does NOT contain:

  • Flask / FastAPI routes
  • Database models
  • Authentication

It is designed to be consumed by your backend application.

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

contentintelpy-0.3.2.tar.gz (56.7 kB view details)

Uploaded Source

Built Distribution

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

contentintelpy-0.3.2-py3-none-any.whl (84.8 kB view details)

Uploaded Python 3

File details

Details for the file contentintelpy-0.3.2.tar.gz.

File metadata

  • Download URL: contentintelpy-0.3.2.tar.gz
  • Upload date:
  • Size: 56.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for contentintelpy-0.3.2.tar.gz
Algorithm Hash digest
SHA256 ade1e054ec65baf6b9cc0bda4dfec5cc595ce93272a3755a00003f602cf8a7ab
MD5 cbaa1a4025077ac34c2671a0ecab2598
BLAKE2b-256 a0081d1bde4ce415b8d2715ab15b27066ecf3bf0d20d6027985821e85f9f95e5

See more details on using hashes here.

File details

Details for the file contentintelpy-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: contentintelpy-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 84.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for contentintelpy-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 615eedb438b6c41e650a3d1a33d56a03ce05eda548cc4253fac5dc07a3c3de3e
MD5 9744dbd2368fa9ca8c2b937439cfd5ea
BLAKE2b-256 6c59061957cca2ce3c9080f61b282d780b8403d509d42ec657970b8ee4c14006

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