Spaces:
Sleeping
Sleeping
app.py
CHANGED
|
@@ -45,6 +45,7 @@ def emphasize_keywords(text, keywords, repeat=3):
|
|
| 45 |
def clean_text(input_text):
|
| 46 |
cleaned = re.sub(r"[^A-Za-z0-9\s]", " ", input_text)
|
| 47 |
cleaned = re.sub(r"\b[A-Za-z]{2,}[0-9]{3,}\b", "", cleaned) # SKU/product code pattern (letters followed by numbers)
|
|
|
|
| 48 |
cleaned = re.sub(r"\b\d+\b", "", cleaned) # Remove numbers as tokens
|
| 49 |
|
| 50 |
# Example keyword list
|
|
@@ -98,7 +99,7 @@ def summarize_text(input_text, model_label, char_limit):
|
|
| 98 |
do_sample=False, # Disable sampling to avoid introducing new words
|
| 99 |
num_beams=5, # Beam search to find the most likely sequence of tokens
|
| 100 |
early_stopping=True, # Stop once a reasonable summary is generated
|
| 101 |
-
no_repeat_ngram_size=
|
| 102 |
)
|
| 103 |
|
| 104 |
|
|
|
|
| 45 |
def clean_text(input_text):
|
| 46 |
cleaned = re.sub(r"[^A-Za-z0-9\s]", " ", input_text)
|
| 47 |
cleaned = re.sub(r"\b[A-Za-z]{2,}[0-9]{3,}\b", "", cleaned) # SKU/product code pattern (letters followed by numbers)
|
| 48 |
+
cleaned = re.sub(r"\b[A-Za-z]{2,}[0-9]{2,}\b", "", cleaned)
|
| 49 |
cleaned = re.sub(r"\b\d+\b", "", cleaned) # Remove numbers as tokens
|
| 50 |
|
| 51 |
# Example keyword list
|
|
|
|
| 99 |
do_sample=False, # Disable sampling to avoid introducing new words
|
| 100 |
num_beams=5, # Beam search to find the most likely sequence of tokens
|
| 101 |
early_stopping=True, # Stop once a reasonable summary is generated
|
| 102 |
+
no_repeat_ngram_size=1 # Prevent repetition of n-grams (bigrams in this case)
|
| 103 |
)
|
| 104 |
|
| 105 |
|