Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -162,17 +162,11 @@ def generate_blog_post(query, prompt_template):
|
|
| 162 |
# λΆνμν νν μ κ±° ν¨μ
|
| 163 |
def remove_unwanted_phrases(text):
|
| 164 |
for phrase in unwanted_phrases:
|
| 165 |
-
#
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
# prev_spaceκ° -1μ΄λ©΄ λ¬Έμμ΄μ μ²μλΆν° μμ
|
| 171 |
-
start = prev_space if prev_space != -1 else 0
|
| 172 |
-
# λΆνμν ννμ λ μμΉ
|
| 173 |
-
end = index + len(phrase)
|
| 174 |
-
# ν΄λΉ λΆλΆ λ¬Έμμ΄ μ κ±°
|
| 175 |
-
text = text[:start] + text[end:]
|
| 176 |
return text
|
| 177 |
|
| 178 |
# μ΄κΈ° ν둬ννΈ κ΅¬μ±
|
|
|
|
| 162 |
# λΆνμν νν μ κ±° ν¨μ
|
| 163 |
def remove_unwanted_phrases(text):
|
| 164 |
for phrase in unwanted_phrases:
|
| 165 |
+
# μ κ·μ ν¨ν΄ μμ±: λΆνμν νν + λ€μ 곡백λ€
|
| 166 |
+
pattern = re.compile(re.escape(phrase) + r'\s*')
|
| 167 |
+
text = pattern.sub('', text)
|
| 168 |
+
# μ°μλ 곡백μ νλμ 곡백μΌλ‘ μΉν
|
| 169 |
+
text = re.sub(r'\s+', ' ', text).strip()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 170 |
return text
|
| 171 |
|
| 172 |
# μ΄κΈ° ν둬ννΈ κ΅¬μ±
|