contentintelpy 0.1.4__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/PKG-INFO +1 -1
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/__init__.py +12 -3
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/sentiment_node.py +22 -16
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/utils/model_registry.py +1 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy.egg-info/PKG-INFO +1 -1
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/pyproject.toml +1 -1
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/LICENSE +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/README.md +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/classification_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/keyword_extract_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/language_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/location_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/ner_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/summarization_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/nodes/translation_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/pipeline/base_node.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/pipeline/context.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/pipeline/pipeline.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/services/ner_service.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/services/sentiment_service.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/services/summarization_service.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/services/translation_service.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/utils/lazy_import.py +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy.egg-info/SOURCES.txt +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy.egg-info/dependency_links.txt +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy.egg-info/requires.txt +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy.egg-info/top_level.txt +0 -0
- {contentintelpy-0.1.4 → contentintelpy-0.1.6}/setup.cfg +0 -0
|
@@ -1,8 +1,17 @@
|
|
|
1
|
+
import warnings
|
|
2
|
+
import os
|
|
3
|
+
import sys
|
|
4
|
+
|
|
5
|
+
# Suppress HuggingFace/Transformers deprecation warnings globally
|
|
6
|
+
warnings.filterwarnings("ignore", category=FutureWarning)
|
|
7
|
+
warnings.filterwarnings("ignore", message=".*TRANSFORMERS_CACHE.*")
|
|
8
|
+
os.environ["TRANSFORMERS_NO_ADVISORY_WARNINGS"] = "1"
|
|
9
|
+
os.environ["HF_HUB_DISABLE_SYMLINKS_WARNING"] = "1"
|
|
10
|
+
|
|
11
|
+
import importlib
|
|
1
12
|
from .pipeline.pipeline import Pipeline
|
|
2
13
|
from .pipeline.context import PipelineContext
|
|
3
14
|
from .pipeline.base_node import Node
|
|
4
|
-
import importlib
|
|
5
|
-
import sys
|
|
6
15
|
|
|
7
16
|
def _show_welcome_hint():
|
|
8
17
|
"""Shows a concise setup hint if core optional dependencies are missing."""
|
|
@@ -13,7 +22,7 @@ def _show_welcome_hint():
|
|
|
13
22
|
YELLOW = "\033[93m"
|
|
14
23
|
RESET = "\033[0m"
|
|
15
24
|
print(f"{YELLOW}⚠️ [ContentIntelPy] Optional ML dependencies are missing. Features like Translation/NER will be disabled.")
|
|
16
|
-
print(f"
|
|
25
|
+
print(f"-> Check README.md or run: pip install \"contentintelpy[core,ner,translation,summarization]\"{RESET}")
|
|
17
26
|
|
|
18
27
|
# Run hint on first import if in an interactive session
|
|
19
28
|
if sys.stdout.isatty():
|
|
@@ -47,25 +47,31 @@ class SentimentNode(Node):
|
|
|
47
47
|
try:
|
|
48
48
|
analyzer = registry.get_sentiment_pipeline()
|
|
49
49
|
# Truncate to model max length (~512 tokens)
|
|
50
|
-
|
|
51
|
-
# Result: [{'label': 'positive', 'score': 0.98}]
|
|
50
|
+
outputs = analyzer(text_to_analyze[:512])
|
|
52
51
|
|
|
53
|
-
if
|
|
54
|
-
|
|
55
|
-
label_en = top['label'].lower() # positive, negative, neutral
|
|
56
|
-
score = top['score']
|
|
52
|
+
if not outputs or not isinstance(outputs, list):
|
|
53
|
+
raise ValueError("Unexpected sentiment output format")
|
|
57
54
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
label_native = self.LABEL_MAP[original_lang].get(label_en, label_en)
|
|
55
|
+
# Handle nested list if pipeline returned list-of-lists (standard for some HF models)
|
|
56
|
+
if len(outputs) > 0 and isinstance(outputs[0], list):
|
|
57
|
+
outputs = outputs[0]
|
|
62
58
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
# The correct sentiment is the entry with the highest score
|
|
60
|
+
top = max(outputs, key=lambda x: x["score"])
|
|
61
|
+
label_en = top['label'].lower() # positive, negative, neutral
|
|
62
|
+
score = top['score']
|
|
63
|
+
|
|
64
|
+
# Resolve Native Label
|
|
65
|
+
label_native = label_en
|
|
66
|
+
if original_lang in self.LABEL_MAP:
|
|
67
|
+
label_native = self.LABEL_MAP[original_lang].get(label_en, label_en)
|
|
68
|
+
|
|
69
|
+
context["sentiment"] = {
|
|
70
|
+
"value": label_native,
|
|
71
|
+
"value_en": label_en,
|
|
72
|
+
"confidence": round(float(score), 4)
|
|
73
|
+
}
|
|
74
|
+
logger.debug(f"Sentiment: {label_en} ({score:.2f})")
|
|
69
75
|
|
|
70
76
|
except Exception as e:
|
|
71
77
|
logger.error(f"Sentiment analysis failed: {e}")
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "contentintelpy"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.6"
|
|
8
8
|
description = "Production-grade NLP library for unified content intelligence."
|
|
9
9
|
authors = [
|
|
10
10
|
{ name = "Ronit Fulari", email = "ronitfulari31@gmail.com" },
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/services/summarization_service.py
RENAMED
|
File without changes
|
{contentintelpy-0.1.4 → contentintelpy-0.1.6}/contentintelpy/services/translation_service.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|