Spaces:
Sleeping
Sleeping
Walid-Ahmed
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,12 @@ def process(context_file, question):
|
|
20 |
raw_data = file.read()
|
21 |
result = chardet.detect(raw_data)
|
22 |
encoding = result['encoding']
|
23 |
-
|
|
|
|
|
|
|
|
|
|
|
24 |
|
25 |
|
26 |
answer = answer_question(context, question)
|
|
|
20 |
raw_data = file.read()
|
21 |
result = chardet.detect(raw_data)
|
22 |
encoding = result['encoding']
|
23 |
+
|
24 |
+
# Fallback to a default encoding if detection fails
|
25 |
+
if encoding is None:
|
26 |
+
encoding = 'utf-8' # You can change this to another default encoding
|
27 |
+
|
28 |
+
context = raw_data.decode(encoding, errors='replace') # Replace errors with a placeholder
|
29 |
|
30 |
|
31 |
answer = answer_question(context, question)
|