Spaces:
Sleeping
Sleeping
Delete tone_analyzer.py
Browse files- tone_analyzer.py +0 -29
tone_analyzer.py
DELETED
|
@@ -1,29 +0,0 @@
|
|
| 1 |
-
def analyze_tone(text, tone_classifier):
|
| 2 |
-
"""
|
| 3 |
-
ESテキストの感情・トーンを分析し、ポジティンブ度と熱意スコアを算出する。
|
| 4 |
-
|
| 5 |
-
Args:
|
| 6 |
-
text (str): 志望動機や自己PRのテキスト。
|
| 7 |
-
tone_classifier (callable): トーン分類器。テキストを入力として受け取り、トーンスコアを返す関数。
|
| 8 |
-
|
| 9 |
-
Returns:
|
| 10 |
-
dict: トーン分析結果(スコアとラベル)。
|
| 11 |
-
"""
|
| 12 |
-
# 感情分析を実行
|
| 13 |
-
# ラベルが'positive'のスコアを熱意スコアとして抽出
|
| 14 |
-
results = tone_classifier(text)
|
| 15 |
-
|
| 16 |
-
# 結果の整形
|
| 17 |
-
result = results[0]
|
| 18 |
-
sentiment_label = result['label']
|
| 19 |
-
sentiment_score = result['score']
|
| 20 |
-
|
| 21 |
-
# ポジティブ度/熱意スコア(0.0~100.0に換算)
|
| 22 |
-
enthusiasm_score = round(sentiment_score *100,2)
|
| 23 |
-
|
| 24 |
-
# 結果を返す
|
| 25 |
-
return {
|
| 26 |
-
"label": sentiment_label,
|
| 27 |
-
"raw_score": sentiment_score,
|
| 28 |
-
"enthusiasm_score": enthusiasm_score
|
| 29 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|