File size: 620 Bytes
36e43c0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
from .text_preprocessor import TextPreprocessor
from .emotion_classifier import EmotionClassifier
from .shift_detector import ShiftDetector
from .explanation_engine import ExplanationEngine
class EmotionShiftPipeline:
def __init__(self):
self.p = TextPreprocessor(); self.c = EmotionClassifier()
self.d = ShiftDetector(); self.e = ExplanationEngine()
def __call__(self, conv):
emotions = [self.c.classify(self.p.clean(t)) for t in conv]
shifts = self.d.detect(emotions)
return {'emotions': emotions, 'shifts': shifts, 'explanations': [self.e.explain(s) for s in shifts]}
|