ginipick commited on
Commit
8bd4269
·
verified ·
1 Parent(s): fada645

Update src/main.py

Browse files
Files changed (1) hide show
  1. src/main.py +24 -22
src/main.py CHANGED
@@ -29,7 +29,29 @@ def is_korean(text):
29
  """한글이 포함되어 있는지 확인"""
30
  return bool(re.search('[가-힣]', text))
31
 
 
 
 
 
 
 
32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
34
  def find_quoted_words(text):
35
  """작은따옴표로 묶인 단어들을 찾는 함수"""
@@ -39,6 +61,7 @@ def spell_out_word(word):
39
  """단어를 개별 알파벳으로 분리하는 함수"""
40
  return ' '.join(list(word.lower()))
41
 
 
42
  def translate_korean_to_english(text):
43
  """전체 텍스트 번역 함수"""
44
  try:
@@ -89,29 +112,8 @@ def translate_korean_to_english(text):
89
  print(f"Translation error: {e}")
90
  return text
91
 
92
- def is_english(text):
93
- """텍스트가 영어인지 확인하는 함수"""
94
- # 따옴표와 공백을 제외한 나머지 텍스트 확인
95
- text_without_quotes = re.sub(r"'[^']*'|\s", "", text)
96
- # 영어 알파벳과 기본 문장부호만 포함되어 있는지 확인
97
- return bool(re.match(r'^[A-Za-z.,!?-]*$', text_without_quotes))
98
 
99
- def normalize_quotes(text):
100
- """따옴표 형식을 정규화하는 함수"""
101
- # 연속된 따옴표 제거
102
- text = re.sub(r"'+", "'", text)
103
- # 불필요한 공백 제거
104
- text = re.sub(r'\s+', ' ', text).strip()
105
-
106
- # 첫 번째 단어에만 따옴표 처리
107
- words = text.split()
108
- if words:
109
- # 모든 따옴표 제거 후 첫 단어에만 따옴표 추가
110
- first_word = words[0].replace("'", "")
111
- words[0] = f"'{first_word}'"
112
- words[1:] = [w.replace("'", "") for w in words[1:]]
113
- return ' '.join(words)
114
- return text
115
 
116
  @app.route('/')
117
  def index():
 
29
  """한글이 포함되어 있는지 확인"""
30
  return bool(re.search('[가-힣]', text))
31
 
32
+ def is_english(text):
33
+ """텍스트가 영어인지 확인하는 함수"""
34
+ # 따옴표와 공백을 제외한 나머지 텍스트 확인
35
+ text_without_quotes = re.sub(r"'[^']*'|\s", "", text)
36
+ # 영어 알파벳과 기본 문장부호만 포함되어 있는지 확인
37
+ return bool(re.match(r'^[A-Za-z.,!?-]*$', text_without_quotes))
38
 
39
+ def normalize_quotes(text):
40
+ """따옴표 형식을 정규화하는 함수"""
41
+ # 연속된 따옴표 제거
42
+ text = re.sub(r"'+", "'", text)
43
+ # 불필요한 공백 제거
44
+ text = re.sub(r'\s+', ' ', text).strip()
45
+
46
+ # 첫 번째 단어에만 따옴표 처리
47
+ words = text.split()
48
+ if words:
49
+ # 모든 따옴표 제거 후 첫 단어에만 따옴표 추가
50
+ first_word = words[0].replace("'", "")
51
+ words[0] = f"'{first_word}'"
52
+ words[1:] = [w.replace("'", "") for w in words[1:]]
53
+ return ' '.join(words)
54
+ return text
55
 
56
  def find_quoted_words(text):
57
  """작은따옴표로 묶인 단어들을 찾는 함수"""
 
61
  """단어를 개별 알파벳으로 분리하는 함수"""
62
  return ' '.join(list(word.lower()))
63
 
64
+
65
  def translate_korean_to_english(text):
66
  """전체 텍스트 번역 함수"""
67
  try:
 
112
  print(f"Translation error: {e}")
113
  return text
114
 
 
 
 
 
 
 
115
 
116
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
 
118
  @app.route('/')
119
  def index():