yosuke-i commited on
Commit
4e798ee
·
verified ·
1 Parent(s): 9a9bd1c

Update kousei.py

Browse files
Files changed (1) hide show
  1. kousei.py +7 -15
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
- # Check for punctuation at the end
35
- if not re.search(r'[.!?。]$', text):
36
- errors.append("文末にピリオドや?や!のいずれかがついていません。")
37
- # Find the last few words as the problematic part
38
- last_words = re.findall(r'[^ ]+ ?[^ ]*$', text)
39
- if last_words:
40
- error_details.append(f"文末にピリオドや?や!のいずれかがついていない部分: '{last_words[0]}'")
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)