valhalla commited on
Commit
7edcd52
1 Parent(s): ea6b249

features_dict => features

Browse files
Files changed (1) hide show
  1. tagging_app.py +22 -22
tagging_app.py CHANGED
@@ -57,45 +57,45 @@ creator_set = {
57
  ########################
58
 
59
  @st.cache
60
- def filter_features(feature_dict):
61
- if isinstance(feature_dict, list):
62
- return dict([(k, filter_features(v)) for k, v in feature_dict[0].items()])
63
- elif feature_dict.get("_type", None) == 'Value':
64
  return {
65
- "feature_type": feature_dict["_type"],
66
- "dtype": feature_dict["dtype"],
67
  }
68
- elif feature_dict.get("_type", None) == 'Sequence':
69
- if "dtype" in feature_dict["feature"]:
70
  return {
71
- "feature_type": feature_dict["_type"],
72
- "feature": filter_features(feature_dict["feature"]),
73
  }
74
- elif "_type" in feature_dict["feature"] and feature_dict["feature"]["_type"] == "ClassLabel":
75
  return {
76
- "feature_type": feature_dict["_type"],
77
  "dtype": "int32",
78
- "feature": filter_features(feature_dict["feature"]),
79
  }
80
  else:
81
  return dict(
82
- [("feature_type", feature_dict["_type"])] + \
83
- [(k, filter_features(v)) for k, v in feature_dict["feature"].items()]
84
  )
85
- elif feature_dict.get("_type", None) == 'ClassLabel':
86
  return {
87
- "feature_type": feature_dict["_type"],
88
  "dtype": "int32",
89
- "class_names": feature_dict["names"],
90
  }
91
- elif feature_dict.get("_type", None) in ['Translation', 'TranslationVariableLanguages']:
92
  return {
93
- "feature_type": feature_dict["_type"],
94
  "dtype": "string",
95
- "languages": feature_dict["languages"],
96
  }
97
  else:
98
- return dict([(k, filter_features(v)) for k, v in feature_dict.items()])
99
 
100
 
101
  @st.cache
 
57
  ########################
58
 
59
  @st.cache
60
+ def filter_features(features):
61
+ if isinstance(features, list):
62
+ return dict([(k, filter_features(v)) for k, v in features[0].items()])
63
+ elif features.get("_type", None) == 'Value':
64
  return {
65
+ "feature_type": features["_type"],
66
+ "dtype": features["dtype"],
67
  }
68
+ elif features.get("_type", None) == 'Sequence':
69
+ if "dtype" in features["feature"]:
70
  return {
71
+ "feature_type": features["_type"],
72
+ "feature": filter_features(features["feature"]),
73
  }
74
+ elif "_type" in features["feature"] and features["feature"]["_type"] == "ClassLabel":
75
  return {
76
+ "feature_type": features["_type"],
77
  "dtype": "int32",
78
+ "feature": filter_features(features["feature"]),
79
  }
80
  else:
81
  return dict(
82
+ [("feature_type", features["_type"])] + \
83
+ [(k, filter_features(v)) for k, v in features["feature"].items()]
84
  )
85
+ elif features.get("_type", None) == 'ClassLabel':
86
  return {
87
+ "feature_type": features["_type"],
88
  "dtype": "int32",
89
+ "class_names": features["names"],
90
  }
91
+ elif features.get("_type", None) in ['Translation', 'TranslationVariableLanguages']:
92
  return {
93
+ "feature_type": features["_type"],
94
  "dtype": "string",
95
+ "languages": features["languages"],
96
  }
97
  else:
98
+ return dict([(k, filter_features(v)) for k, v in features.items()])
99
 
100
 
101
  @st.cache