Update kousei.py
Browse files
kousei.py
CHANGED
|
@@ -17,7 +17,6 @@ import tempfile
|
|
| 17 |
import os
|
| 18 |
import re
|
| 19 |
|
| 20 |
-
import re
|
| 21 |
|
| 22 |
def check_text(text):
|
| 23 |
errors = []
|
|
@@ -31,20 +30,13 @@ def check_text(text):
|
|
| 31 |
for part in multiple_spaces_parts:
|
| 32 |
error_details.append(f"半角スペースが2つ以上続いている部分: '{part.strip()}'")
|
| 33 |
|
| 34 |
-
#
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
#
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
error_details.append(f"文末に
|
| 41 |
-
|
| 42 |
-
# Check if 【正解選択肢】 ends with "。"
|
| 43 |
-
correct_choice_lines = re.findall(r'【正解選択肢】.*', text)
|
| 44 |
-
for line in correct_choice_lines:
|
| 45 |
-
if not line.endswith("。"):
|
| 46 |
-
errors.append("【正解選択肢】の文末に「。」がついていません。")
|
| 47 |
-
error_details.append(f"【正解選択肢】の文末に「。」がついていない部分: '{line}'")
|
| 48 |
|
| 49 |
if errors:
|
| 50 |
return "チェック観点:\n" + "\n".join(errors) + "\n\n詳細:\n" + "\n".join(error_details)
|
|
|
|
| 17 |
import os
|
| 18 |
import re
|
| 19 |
|
|
|
|
| 20 |
|
| 21 |
def check_text(text):
|
| 22 |
errors = []
|
|
|
|
| 30 |
for part in multiple_spaces_parts:
|
| 31 |
error_details.append(f"半角スペースが2つ以上続いている部分: '{part.strip()}'")
|
| 32 |
|
| 33 |
+
# Split the text into lines for individual sentence checks
|
| 34 |
+
lines = text.split("\n")
|
| 35 |
+
for line in lines:
|
| 36 |
+
# Check for punctuation at the end of each line
|
| 37 |
+
if not re.search(r'[。!]$', line.strip()):
|
| 38 |
+
errors.append("文末に「。」や「!」がついていません。")
|
| 39 |
+
error_details.append(f"文末に「。」や「!」がついていない部分: '{line.strip()}'")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
|
| 41 |
if errors:
|
| 42 |
return "チェック観点:\n" + "\n".join(errors) + "\n\n詳細:\n" + "\n".join(error_details)
|