Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -53,7 +53,7 @@ for filepath in glob.glob("data/*.txt"):
|
|
| 53 |
|
| 54 |
combined_text = "\n".join(all_texts)
|
| 55 |
|
| 56 |
-
|
| 57 |
def preprocess_text(text):
|
| 58 |
# Strip extra whitespace from the beginning and the end of the text
|
| 59 |
cleaned_text = text.strip()
|
|
@@ -61,12 +61,9 @@ def preprocess_text(text):
|
|
| 61 |
chunks = cleaned_text.split("\n")
|
| 62 |
|
| 63 |
# Create an empty list to store cleaned chunks
|
| 64 |
-
cleaned_chunks = []
|
| 65 |
|
| 66 |
# Write your for-in loop below to clean each chunk and add it to the cleaned_chunks list
|
| 67 |
-
for chunk in chunks:
|
| 68 |
-
stripped_chunk = chunk.strip()
|
| 69 |
-
cleaned_chunks.append(stripped_chunk)
|
| 70 |
|
| 71 |
# Print cleaned_chunks
|
| 72 |
print(cleaned_chunks)
|
|
|
|
| 53 |
|
| 54 |
combined_text = "\n".join(all_texts)
|
| 55 |
|
| 56 |
+
|
| 57 |
def preprocess_text(text):
|
| 58 |
# Strip extra whitespace from the beginning and the end of the text
|
| 59 |
cleaned_text = text.strip()
|
|
|
|
| 61 |
chunks = cleaned_text.split("\n")
|
| 62 |
|
| 63 |
# Create an empty list to store cleaned chunks
|
| 64 |
+
cleaned_chunks = [chunk.strip() for chunk in chunks if chunk.strip()]
|
| 65 |
|
| 66 |
# Write your for-in loop below to clean each chunk and add it to the cleaned_chunks list
|
|
|
|
|
|
|
|
|
|
| 67 |
|
| 68 |
# Print cleaned_chunks
|
| 69 |
print(cleaned_chunks)
|