OxbridgeEconomics
commited on
Update utils.py
Browse files- controllers/utils.py +6 -3
controllers/utils.py
CHANGED
@@ -675,9 +675,12 @@ def crawl_by_url(url, article):
|
|
675 |
contenteng = ''
|
676 |
for element in contentcn.split("\n"):
|
677 |
contenteng += translate(element) + '\n'
|
678 |
-
|
679 |
-
|
680 |
-
|
|
|
|
|
|
|
681 |
article['content'] = repr(contenteng)[1:-1].strip()
|
682 |
try:
|
683 |
article['subtitle'] = summarize(article['content'])
|
|
|
675 |
contenteng = ''
|
676 |
for element in contentcn.split("\n"):
|
677 |
contenteng += translate(element) + '\n'
|
678 |
+
try:
|
679 |
+
if detect(contenteng) != 'en':
|
680 |
+
for element in contentcn.split("。"):
|
681 |
+
contenteng += translate(element) + '. '
|
682 |
+
except Exception as e:
|
683 |
+
print(f"An unexpected error occurred: {e}")
|
684 |
article['content'] = repr(contenteng)[1:-1].strip()
|
685 |
try:
|
686 |
article['subtitle'] = summarize(article['content'])
|