Skip to content

Instantly share code, notes, and snippets.

@amankharwal
Created February 19, 2021 07:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amankharwal/5e3f4ec7df3104784c8056b31d2baebd to your computer and use it in GitHub Desktop.
Save amankharwal/5e3f4ec7df3104784c8056b31d2baebd to your computer and use it in GitHub Desktop.
def convert_label(item, name):
items = list(map(float, item.split()))
label = ""
for idx in range(len(items)):
if items[idx] == 1:
label += name[idx] + " "
return label.strip()
emotions = ["joy", 'fear', "anger", "sadness", "disgust", "shame", "guilt"]
X_all = []
y_all = []
for label, text in data:
y_all.append(convert_label(label, emotions))
X_all.append(create_feature(text, nrange=(1, 4)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment