contentintelpy 0.1.4__py3-none-any.whl → 0.1.6__py3-none-any.whl

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.
@@ -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" Check README.md or run: pip install \"contentintelpy[core,ner,translation,summarization]\"{RESET}")
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
- result = analyzer(text_to_analyze[:512])
51
- # Result: [{'label': 'positive', 'score': 0.98}]
50
+ outputs = analyzer(text_to_analyze[:512])
52
51
 
53
- if result and len(result) > 0:
54
- top = result[0]
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
- # Resolve Native Label
59
- label_native = label_en
60
- if original_lang in self.LABEL_MAP:
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
- context["sentiment"] = {
64
- "value": label_native,
65
- "value_en": label_en,
66
- "confidence": round(score, 4)
67
- }
68
- logger.debug(f"Sentiment: {label_en} ({score:.2f})")
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}")
@@ -6,6 +6,7 @@ import warnings
6
6
 
7
7
  # Suppress HuggingFace warnings for cleaner logs
8
8
  warnings.filterwarnings("ignore", category=UserWarning)
9
+ warnings.filterwarnings("ignore", category=FutureWarning)
9
10
 
10
11
  logger = logging.getLogger("contentintelpy.registry")
11
12
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: contentintelpy
3
- Version: 0.1.4
3
+ Version: 0.1.6
4
4
  Summary: Production-grade NLP library for unified content intelligence.
5
5
  Author-email: Ronit Fulari <ronitfulari31@gmail.com>
6
6
  License: MIT
@@ -1,10 +1,10 @@
1
- contentintelpy/__init__.py,sha256=cQkzOULSS0r-jaSIF15tjYypuAJ9ez3T6LnEaZpat44,2678
1
+ contentintelpy/__init__.py,sha256=j_4VSIgI5_zMyvl_Bi-TKP6C8I6mzWVFrbn-dkhgk3Y,3012
2
2
  contentintelpy/nodes/classification_node.py,sha256=ivfAHdYXZU-5eVbtgxD94_TiRHcq-mJg4ukOc7KqwXU,2116
3
3
  contentintelpy/nodes/keyword_extract_node.py,sha256=o-OTOdkdEIYnd_ZczdAjwJkWnjzlKLa28WnEZCKy_og,3024
4
4
  contentintelpy/nodes/language_node.py,sha256=sKRa65kLrb1IRYGrkT82tu8LgdhIXdN5EwhUrH6pSqI,1971
5
5
  contentintelpy/nodes/location_node.py,sha256=U3YQ31KclWNeoyrorodBAzAEd7zLmI31Deu72Viw1M0,1579
6
6
  contentintelpy/nodes/ner_node.py,sha256=8DRg7NVpz8ZXcobgwYZsWkNOvaFfIj_ZEWG8wJckqus,1632
7
- contentintelpy/nodes/sentiment_node.py,sha256=oFuw1Z0d6f4BWSYtnp8UN0gMCvL3nl5b4h68t6qv-cQ,2706
7
+ contentintelpy/nodes/sentiment_node.py,sha256=LzKCjhF1Q0iI4J9vC_8WPGzeTWIu5p_1lDgoFUox8oo,3000
8
8
  contentintelpy/nodes/summarization_node.py,sha256=XHdT8lMN-1_fiGBGkqbblPfJgkvQTf7XIq99z7w_6Bw,2803
9
9
  contentintelpy/nodes/translation_node.py,sha256=zebwFqp22bo4Oi5gKyNGZKduAl_grfZTC53PKPsKVko,4511
10
10
  contentintelpy/pipeline/base_node.py,sha256=hYLx2yAURpbmTr9x4kG8qVIlNI1Q0UJckBltW5LJl-o,1394
@@ -15,9 +15,9 @@ contentintelpy/services/sentiment_service.py,sha256=Yc6u0l8m_uN5ZxgUMr9DQziwi50c
15
15
  contentintelpy/services/summarization_service.py,sha256=XK3vAGGoQS1dXxaO4nKjyrFlWwN_wZKY2qFNcDJ9IIM,748
16
16
  contentintelpy/services/translation_service.py,sha256=6yNLLJ7mAE7ptHvprX1JUoUN-65Ot7ZdTszqqxMY1TA,1191
17
17
  contentintelpy/utils/lazy_import.py,sha256=izXzPtoTUfkd6ee_7QFqE-IARd5NBe2_W6-pCbS2e2o,956
18
- contentintelpy/utils/model_registry.py,sha256=e8KK1AiZ1jJvsxNwapQjNLKiCeETZd8gWJKaoO-Bl_E,5823
19
- contentintelpy-0.1.4.dist-info/licenses/LICENSE,sha256=lZ8hT4isGfdFVxdD7gDRnt3RJqyrkO1L5GseyN3A9hM,1092
20
- contentintelpy-0.1.4.dist-info/METADATA,sha256=D5jLyccG6ZShV24EdaKnzAaFaoHy1_0IsdX0pMLhkhs,5085
21
- contentintelpy-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
22
- contentintelpy-0.1.4.dist-info/top_level.txt,sha256=sxoE-r2-frUi3qwADEiYcFFxZW5hMI1Mjw87hcGMulQ,15
23
- contentintelpy-0.1.4.dist-info/RECORD,,
18
+ contentintelpy/utils/model_registry.py,sha256=Zk52vJy4wtN2zcYnqOtWJTgbAGMQUYj3LFqHJBiILXY,5882
19
+ contentintelpy-0.1.6.dist-info/licenses/LICENSE,sha256=lZ8hT4isGfdFVxdD7gDRnt3RJqyrkO1L5GseyN3A9hM,1092
20
+ contentintelpy-0.1.6.dist-info/METADATA,sha256=bEW5BVMGbrqLoKrcFDqQKf5AsKlyqG6NjABcpK31ecw,5085
21
+ contentintelpy-0.1.6.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
22
+ contentintelpy-0.1.6.dist-info/top_level.txt,sha256=sxoE-r2-frUi3qwADEiYcFFxZW5hMI1Mjw87hcGMulQ,15
23
+ contentintelpy-0.1.6.dist-info/RECORD,,