Update convert_chukan_fmt_1.py
Browse files- convert_chukan_fmt_1.py +7 -4
convert_chukan_fmt_1.py
CHANGED
|
@@ -56,11 +56,14 @@ def shuffle_and_combine_options(text_a, text_b):
|
|
| 56 |
return result_a, result_b
|
| 57 |
|
| 58 |
# 解説作成
|
| 59 |
-
def create_explanation(script_english,script_japanese,choices_english, choices_japanese):
|
| 60 |
choices_english = choices_english.replace("/", "\n")
|
| 61 |
choices_japanese = choices_japanese.replace("/", "\n")
|
| 62 |
-
|
|
|
|
|
|
|
| 63 |
return explanation
|
|
|
|
| 64 |
def convert_chukan_fmt_1(csv_file):
|
| 65 |
df_input = pd.read_csv(csv_file.name)
|
| 66 |
data = {
|
|
@@ -89,7 +92,7 @@ def convert_chukan_fmt_1(csv_file):
|
|
| 89 |
data["問題"].append("")
|
| 90 |
data["問題_翻訳"].append(extract_correct_choice(row["日本語訳_問題1_選択肢"]))
|
| 91 |
data["正解文"].append(extract_correct_choice(row["問題1_選択肢"]))
|
| 92 |
-
data["解説テキスト"].append(create_explanation(row["問題1_スクリプト"], row["日本語訳_問題1_スクリプト"], english_selection_1, japanese_selection_1))
|
| 93 |
data["選択肢"].append(english_selection_1)
|
| 94 |
data["正解"].append(extract_correct_choice(row["問題1_選択肢"]))
|
| 95 |
data["script"].append(row["問題1_スクリプト"])
|
|
@@ -106,7 +109,7 @@ def convert_chukan_fmt_1(csv_file):
|
|
| 106 |
data["問題"].append("")
|
| 107 |
data["問題_翻訳"].append(extract_correct_choice(row["日本語訳_問題2_選択肢"]))
|
| 108 |
data["正解文"].append(extract_correct_choice(row["問題2_選択肢"]))
|
| 109 |
-
data["解説テキスト"].append(create_explanation(row["問題2_スクリプト"], row["日本語訳_問題2_スクリプト"], english_selection_2, japanese_selection_2))
|
| 110 |
data["選択肢"].append(english_selection_2)
|
| 111 |
data["正解"].append(extract_correct_choice(row["問題2_選択肢"]))
|
| 112 |
data["script"].append(row["問題2_スクリプト"])
|
|
|
|
| 56 |
return result_a, result_b
|
| 57 |
|
| 58 |
# 解説作成
|
| 59 |
+
def create_explanation(script_english,script_japanese,choices_english, choices_japanese,question_english,question_japanese):
|
| 60 |
choices_english = choices_english.replace("/", "\n")
|
| 61 |
choices_japanese = choices_japanese.replace("/", "\n")
|
| 62 |
+
question_english = "" if question_english == "" else "\n\nQuestion:\n" + question_english
|
| 63 |
+
question_japanese = "" if question_japanese == "" else "\n\nQuestion:\n" + question_japanese
|
| 64 |
+
explanation = f"■英語\n{script_english}{question_english}\n\n選択肢:\n{choices_english}\n\n■日本語訳\n{script_japanese}{question_japanese}\n\n選択肢:\n{choices_japanese}"
|
| 65 |
return explanation
|
| 66 |
+
|
| 67 |
def convert_chukan_fmt_1(csv_file):
|
| 68 |
df_input = pd.read_csv(csv_file.name)
|
| 69 |
data = {
|
|
|
|
| 92 |
data["問題"].append("")
|
| 93 |
data["問題_翻訳"].append(extract_correct_choice(row["日本語訳_問題1_選択肢"]))
|
| 94 |
data["正解文"].append(extract_correct_choice(row["問題1_選択肢"]))
|
| 95 |
+
data["解説テキスト"].append(create_explanation(row["問題1_スクリプト"], row["日本語訳_問題1_スクリプト"], english_selection_1, japanese_selection_1, row["問題1_Question"], row["日本語訳_問題1_Question"]))
|
| 96 |
data["選択肢"].append(english_selection_1)
|
| 97 |
data["正解"].append(extract_correct_choice(row["問題1_選択肢"]))
|
| 98 |
data["script"].append(row["問題1_スクリプト"])
|
|
|
|
| 109 |
data["問題"].append("")
|
| 110 |
data["問題_翻訳"].append(extract_correct_choice(row["日本語訳_問題2_選択肢"]))
|
| 111 |
data["正解文"].append(extract_correct_choice(row["問題2_選択肢"]))
|
| 112 |
+
data["解説テキスト"].append(create_explanation(row["問題2_スクリプト"], row["日本語訳_問題2_スクリプト"], english_selection_2, japanese_selection_2, row["問題2_Question"], row["日本語訳_問題2_Question"]))
|
| 113 |
data["選択肢"].append(english_selection_2)
|
| 114 |
data["正解"].append(extract_correct_choice(row["問題2_選択肢"]))
|
| 115 |
data["script"].append(row["問題2_スクリプト"])
|