Spaces:
Runtime error
Runtime error
quyip
commited on
Commit
·
ed04ca3
1
Parent(s):
02f8d21
fix
Browse files- utils/summary_utils.py +1 -17
utils/summary_utils.py
CHANGED
|
@@ -6,7 +6,6 @@ from utils.tag_utils import filter_tags
|
|
| 6 |
AiSummaryVersion = 4
|
| 7 |
summarization_pipeline = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum")
|
| 8 |
en_translation_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
|
| 9 |
-
classification_pipe = pipeline("text-classification", model="Yueh-Huan/news-category-classification-distilbert")
|
| 10 |
text_to_tags_pipe = pipeline('text2text-generation', model='models/text2tags')
|
| 11 |
|
| 12 |
|
|
@@ -17,9 +16,7 @@ def summarize(id: str, text: str):
|
|
| 17 |
}
|
| 18 |
summary = get_summarization(text) if len(text) > 100 else text
|
| 19 |
translated = get_en_translation(summary)
|
| 20 |
-
|
| 21 |
-
tags2 = get_tags(translated)
|
| 22 |
-
tags = filter_tags(tags1 + tags2)
|
| 23 |
tags = sorted(list(set(tags)))
|
| 24 |
|
| 25 |
value = {
|
|
@@ -68,16 +65,3 @@ def get_tags(text: str):
|
|
| 68 |
return [tag.strip() for tag in tag_str.split(',')]
|
| 69 |
except:
|
| 70 |
return []
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
def get_classification(text: str):
|
| 74 |
-
if text is None:
|
| 75 |
-
return []
|
| 76 |
-
try:
|
| 77 |
-
result = classification_pipe(text)
|
| 78 |
-
if isinstance(result, list):
|
| 79 |
-
return [tag['label'].strip() for tag in result if tag['score'] > 0.75]
|
| 80 |
-
else:
|
| 81 |
-
return [result['label'].strip()] if result['score'] > 0.75 else []
|
| 82 |
-
except:
|
| 83 |
-
return []
|
|
|
|
| 6 |
AiSummaryVersion = 4
|
| 7 |
summarization_pipeline = pipeline("summarization", model="csebuetnlp/mT5_multilingual_XLSum")
|
| 8 |
en_translation_pipe = pipeline("translation", model="Helsinki-NLP/opus-mt-mul-en")
|
|
|
|
| 9 |
text_to_tags_pipe = pipeline('text2text-generation', model='models/text2tags')
|
| 10 |
|
| 11 |
|
|
|
|
| 16 |
}
|
| 17 |
summary = get_summarization(text) if len(text) > 100 else text
|
| 18 |
translated = get_en_translation(summary)
|
| 19 |
+
tags = get_tags(translated)
|
|
|
|
|
|
|
| 20 |
tags = sorted(list(set(tags)))
|
| 21 |
|
| 22 |
value = {
|
|
|
|
| 65 |
return [tag.strip() for tag in tag_str.split(',')]
|
| 66 |
except:
|
| 67 |
return []
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|