taratrankennedy commited on
Commit
ab83d43
1 Parent(s): 9b175d5

Reverting back to the original

Browse files
Files changed (1) hide show
  1. app.py +7 -7
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 restaurant data from a CSV file.
25
  """
26
  try:
27
- df = pd.read_csv(filename)
28
- print("Data loaded successfully.")
29
- return df
 
30
  except Exception as e:
31
- print(f"Failed to load or preprocess data: {e}")
32
- return pd.DataFrame()
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):