Spaces:
Runtime error
Runtime error
replace links and usernames for transformers
Browse files- main-script.py +4 -3
main-script.py
CHANGED
|
@@ -145,8 +145,9 @@ def process_and_save(file_path: str, raw_text: str, url: str, title: str, scrape
|
|
| 145 |
Processes the raw text into two versions (Transformers & TF-IDF) and saves a single JSON.
|
| 146 |
"""
|
| 147 |
# 1. Prepare Transformers Text
|
| 148 |
-
|
| 149 |
-
|
|
|
|
| 150 |
# 2. Prepare TF-IDF Text (Heavy cleaning)
|
| 151 |
tf_text = raw_text
|
| 152 |
tf_text = scraper_helper.lowercase_text(text=tf_text)
|
|
@@ -165,7 +166,7 @@ def process_and_save(file_path: str, raw_text: str, url: str, title: str, scrape
|
|
| 165 |
"title": title,
|
| 166 |
"url": url,
|
| 167 |
"date_scraped": datetime.now().isoformat(), # Added date
|
| 168 |
-
"transformers_text":
|
| 169 |
"tf_idf_text": tf_text
|
| 170 |
}
|
| 171 |
|
|
|
|
| 145 |
Processes the raw text into two versions (Transformers & TF-IDF) and saves a single JSON.
|
| 146 |
"""
|
| 147 |
# 1. Prepare Transformers Text
|
| 148 |
+
transformers_text = scraper_helper.replace_urls(text=raw_text)
|
| 149 |
+
transformers_text = scraper_helper.replace_usernames(text=transformers_text)
|
| 150 |
+
|
| 151 |
# 2. Prepare TF-IDF Text (Heavy cleaning)
|
| 152 |
tf_text = raw_text
|
| 153 |
tf_text = scraper_helper.lowercase_text(text=tf_text)
|
|
|
|
| 166 |
"title": title,
|
| 167 |
"url": url,
|
| 168 |
"date_scraped": datetime.now().isoformat(), # Added date
|
| 169 |
+
"transformers_text": transformers_text,
|
| 170 |
"tf_idf_text": tf_text
|
| 171 |
}
|
| 172 |
|