Spaces:
Sleeping
Sleeping
Delete star_checker.py
Browse files- star_checker.py +0 -52
star_checker.py
DELETED
|
@@ -1,52 +0,0 @@
|
|
| 1 |
-
import json
|
| 2 |
-
|
| 3 |
-
def check_star_sitabillity(self_pr_text, str_classifier):
|
| 4 |
-
"""
|
| 5 |
-
自己PRテキストがSTAR法(Situation, Task, Action, Result)に適合しているかをチェックする。
|
| 6 |
-
Args:
|
| 7 |
-
self_pr_text (str): 自己PRセクションのテキスト。
|
| 8 |
-
str_classifier (function): Hugging faceのZero-shot Classificationパイプライン。
|
| 9 |
-
Returns:
|
| 10 |
-
dict: STAR適合度チェックの結果(適合度スコアとJSPM形式の理由)。
|
| 11 |
-
"""
|
| 12 |
-
# STAR法の各要素に対応する Zero-Shot Classification の候補ラベル
|
| 13 |
-
candidate_labels = ["状況(Situation)", "課題(Task)", "行動(Action)", "結果(Result)"]
|
| 14 |
-
|
| 15 |
-
# Zero-Shot Classification の実行
|
| 16 |
-
star_results = str_classifier(
|
| 17 |
-
self_pr_text,
|
| 18 |
-
candidate_labels,
|
| 19 |
-
multi_label=True # 複数の要素が同時に含まれる可能性があるため
|
| 20 |
-
)
|
| 21 |
-
|
| 22 |
-
#結果の処理
|
| 23 |
-
star_scores = {label: round(score*100, 2) for label, score in zip(star_results['labels'], star_results['scores'])}
|
| 24 |
-
|
| 25 |
-
# 適合度と算出の理由の特定
|
| 26 |
-
# 基準として、スコアが70%未満の要素を「不足」とみなす
|
| 27 |
-
insufficiency_threshold = 70.0
|
| 28 |
-
missing_elements = []
|
| 29 |
-
|
| 30 |
-
total_score = 0
|
| 31 |
-
for label, score in star_scores.items():
|
| 32 |
-
total_score += score
|
| 33 |
-
if score < insufficiency_threshold:
|
| 34 |
-
missing_elements.append(label)
|
| 35 |
-
|
| 36 |
-
#総合適合度スコア(4要素の平均スコア)
|
| 37 |
-
suitability_score = round(total_score / len(candidate_labels), 2)
|
| 38 |
-
|
| 39 |
-
#論理的でない場合の理由をJSONライクな形で出力
|
| 40 |
-
analysis_reason = {
|
| 41 |
-
"suitabilitiy_score": suitability_score,
|
| 42 |
-
"is_logical":suitability_score >= 75.0, # 例: 平均75点以上で論理的と判断
|
| 43 |
-
"reason_code":"LOGICAL_STRUCTURE_GOOD" if not missing_elements else "ELEMENTS_MISSING",
|
| 44 |
-
"missing_elements": missing_elements,
|
| 45 |
-
"detail_scores": star_scores
|
| 46 |
-
}
|
| 47 |
-
|
| 48 |
-
# 結果を返す
|
| 49 |
-
return {
|
| 50 |
-
"suitability_score": suitability_score,
|
| 51 |
-
"analysis_json": analysis_reason
|
| 52 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|