Spaces:
Runtime error
Runtime error
Reverting back to the original
Browse files
app.py
CHANGED
|
@@ -19,17 +19,17 @@ try:
|
|
| 19 |
except Exception as e:
|
| 20 |
print(f"Failed to load models: {e}")
|
| 21 |
|
| 22 |
-
def load_and_preprocess_text(filename):
|
| 23 |
"""
|
| 24 |
-
Load and preprocess
|
| 25 |
"""
|
| 26 |
try:
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
|
|
|
| 30 |
except Exception as e:
|
| 31 |
-
print(f"Failed to load or preprocess
|
| 32 |
-
return
|
| 33 |
|
| 34 |
segments = load_and_preprocess_text(filename)
|
| 35 |
def find_relevant_segment(user_query, segments):
|
|
|
|
| 19 |
except Exception as e:
|
| 20 |
print(f"Failed to load models: {e}")
|
| 21 |
|
|
|
|
| 22 |
"""
|
| 23 |
+
Load and preprocess text from a file, removing empty lines and stripping whitespace.
|
| 24 |
"""
|
| 25 |
try:
|
| 26 |
+
with open(filename, 'r', encoding='utf-8') as file:
|
| 27 |
+
segments = [line.strip() for line in file if line.strip()]
|
| 28 |
+
print("Text loaded and preprocessed successfully.")
|
| 29 |
+
return segments
|
| 30 |
except Exception as e:
|
| 31 |
+
print(f"Failed to load or preprocess text: {e}")
|
| 32 |
+
return []
|
| 33 |
|
| 34 |
segments = load_and_preprocess_text(filename)
|
| 35 |
def find_relevant_segment(user_query, segments):
|