yacine commited on
Commit
fbdf16b
1 Parent(s): ed58320

filter_features for Sequence of ClassLabels

Browse files
Files changed (1) hide show
  1. tagging_app.py +8 -1
tagging_app.py CHANGED
@@ -63,6 +63,12 @@ def filter_features(feature_dict):
63
  "feature_type": feature_dict["_type"],
64
  "feature": filter_features(feature_dict["feature"]),
65
  }
 
 
 
 
 
 
66
  else:
67
  return dict(
68
  [("feature_type", feature_dict["_type"])] + \
@@ -83,6 +89,7 @@ def filter_features(feature_dict):
83
  else:
84
  return dict([(k, filter_features(v)) for k, v in feature_dict.items()])
85
 
 
86
  @st.cache
87
  def find_languages(feature_dict):
88
  if type(feature_dict) in [dict, datasets.features.Features]:
@@ -176,7 +183,7 @@ dataset_id = st.sidebar.selectbox(
176
 
177
  if dataset_id == "local dataset":
178
  path_to_info = st.sidebar.text_input("Please enter the path to the folder where the dataset_infos.json file was generated", "/path/to/dataset/")
179
- if path_to_info != "/path/to/dataset/":
180
  dataset_infos = json.load(open(pjoin(path_to_info, "dataset_infos.json")))
181
  confs = dataset_infos.keys()
182
  all_info_dicts = {}
 
63
  "feature_type": feature_dict["_type"],
64
  "feature": filter_features(feature_dict["feature"]),
65
  }
66
+ elif "_type" in feature_dict["feature"] and feature_dict["feature"]["_type"] == "ClassLabel":
67
+ return {
68
+ "feature_type": feature_dict["_type"],
69
+ "dtype": "int32",
70
+ "feature": filter_features(feature_dict["feature"]),
71
+ }
72
  else:
73
  return dict(
74
  [("feature_type", feature_dict["_type"])] + \
 
89
  else:
90
  return dict([(k, filter_features(v)) for k, v in feature_dict.items()])
91
 
92
+
93
  @st.cache
94
  def find_languages(feature_dict):
95
  if type(feature_dict) in [dict, datasets.features.Features]:
 
183
 
184
  if dataset_id == "local dataset":
185
  path_to_info = st.sidebar.text_input("Please enter the path to the folder where the dataset_infos.json file was generated", "/path/to/dataset/")
186
+ if path_to_info not in ["/path/to/dataset/", ""]:
187
  dataset_infos = json.load(open(pjoin(path_to_info, "dataset_infos.json")))
188
  confs = dataset_infos.keys()
189
  all_info_dicts = {}