sequenceDiagram
participant SS as signal_service
participant SE as sentiment.py
participant CL as claude CLI (subprocess)
SS->>SE: score(headlines)
alt headlines 비어있음
SE-->>SS: 0.0 (NEUTRAL)
else headlines 있음
SE->>CL: subprocess.run(["claude","-p", prompt], timeout=120)
alt timeout 또는 호출 실패
SE-->>SS: 0.0 (NEUTRAL)
else 정상 응답
CL-->>SE: {"score": -1~1, "label": "..."}
alt JSON 파싱 실패
SE-->>SS: 0.0 (NEUTRAL)
else 파싱 성공
SE->>SE: clamp(score, -1, 1)
SE-->>SS: sentiment_score: float
end
end
end
클래스 의존
flowchart LR
subgraph Application["Application"]
signal_service["signal_service.py"]
end
subgraph Domain["Domain"]
sentiment["sentiment.py (score)"]
end
subgraph External["External"]
claude_cli["claude CLI (subprocess)"]
end
signal_service --> sentiment
sentiment --> claude_cli
테스트 케이스
헤드라인이 0건이면 즉시 중립(0.0)을 반환한다.
claude -p 응답이 유효한 JSON {"score":0.8,"label":"긍정"}이면 클램핑 후 반환한다.