bjorn-hommel commited on
Commit
ad021d6
1 Parent(s): 1ababcd
Files changed (3) hide show
  1. app.py +8 -4
  2. modeling.py +4 -2
  3. utils.py +1 -1
app.py CHANGED
@@ -79,9 +79,9 @@ def show_demo(placeholder):
79
  if submitted:
80
 
81
  try:
82
- yaml_dict = yaml.safe_load(input_yaml)
83
  except yaml.YAMLError as e:
84
- st.error(f"Yikes, you better get your YAML straight! Check https://yaml.org/ for help!")
85
  return(None)
86
 
87
  try:
@@ -94,14 +94,18 @@ def show_demo(placeholder):
94
  try:
95
  st.session_state.input_data = modeling.process_yaml_input(yaml_dict)
96
  except Exception as error:
97
- st.error(error)
 
 
98
  st.json(yaml_dict)
99
  return(None)
100
 
101
  try:
102
  st.session_state.input_data = modeling.encode_input_data()
103
  except Exception as error:
104
- st.error(error)
 
 
105
  st.json(yaml_dict)
106
  return(None)
107
 
 
79
  if submitted:
80
 
81
  try:
82
+ yaml_dict = yaml.safe_load(input_yaml)
83
  except yaml.YAMLError as e:
84
+ st.error(f"Yikes, you better get your YAML straight! Check https://yaml.org/ for help!")
85
  return(None)
86
 
87
  try:
 
94
  try:
95
  st.session_state.input_data = modeling.process_yaml_input(yaml_dict)
96
  except Exception as error:
97
+ error_msg = f"Error while processing YAML-input: {error}"
98
+ st.error(error_msg)
99
+
100
  st.json(yaml_dict)
101
  return(None)
102
 
103
  try:
104
  st.session_state.input_data = modeling.encode_input_data()
105
  except Exception as error:
106
+ error_msg = f"Error while encoding data: {error}"
107
+ st.error(error_msg)
108
+ print(error)
109
  st.json(yaml_dict)
110
  return(None)
111
 
modeling.py CHANGED
@@ -29,8 +29,9 @@ def load_model():
29
  logging.info('Loaded SurveyBot3000!')
30
 
31
  def process_yaml_input(yaml_dict):
32
-
33
  input_data = pd.DataFrame({k: pd.Series(v) for k, v in yaml_dict.items()})
 
34
  df = (
35
  input_data
36
  .stack()
@@ -38,8 +39,9 @@ def process_yaml_input(yaml_dict):
38
  .drop('level_0', axis=1)
39
  .rename(columns={'level_1': 'scale', 0: "item"})
40
  )
 
41
  df['item'] = df['item'].apply(lambda item: utils.clean_text(item))
42
-
43
  return(df)
44
 
45
  def get_items_per_scale():
 
29
  logging.info('Loaded SurveyBot3000!')
30
 
31
  def process_yaml_input(yaml_dict):
32
+
33
  input_data = pd.DataFrame({k: pd.Series(v) for k, v in yaml_dict.items()})
34
+
35
  df = (
36
  input_data
37
  .stack()
 
39
  .drop('level_0', axis=1)
40
  .rename(columns={'level_1': 'scale', 0: "item"})
41
  )
42
+
43
  df['item'] = df['item'].apply(lambda item: utils.clean_text(item))
44
+
45
  return(df)
46
 
47
  def get_items_per_scale():
utils.py CHANGED
@@ -4,7 +4,7 @@ import json
4
  import hashlib
5
  from io import StringIO
6
  from datetime import datetime
7
-
8
  def clean_text(input):
9
 
10
  text = ftfy.fix_text(input)
 
4
  import hashlib
5
  from io import StringIO
6
  from datetime import datetime
7
+
8
  def clean_text(input):
9
 
10
  text = ftfy.fix_text(input)