fix wp bug in music skill
@@ -354,16 +354,19 @@ def get_genre(vars):
return "80s"
elif re.search(seventies_re, human_utt):
return "70s"
- wiki_parser = state_utils.get_last_human_utterance(vars)["annotations"].get("wiki_parser", {'entities_info': {}})
- for entity in wiki_parser['entities_info']:
- logger.info(f"Entity: {wiki_parser['entities_info'][entity]}")
- if "genre" in wiki_parser['entities_info'][entity]:
+ wp_output = state_utils.get_last_human_utterance(vars)["annotations"].get("wiki_parser", {})
+ all_entities_info = wp_output.get("entities_info", {})
+ topic_skill_entities_info = wp_output.get("topic_skill_entities_info", {})
+ for entities_info in [all_entities_info, topic_skill_entities_info]:
+ for entity in entities_info:
+ logger.info(f"Entity: {entities_info[entity]}")
+ if "genre" in entities_info[entity]:
for genre in genres:
- for entity_genre in wiki_parser['entities_info'][entity]['genre']:
+ for entity_genre in entities_info[entity]['genre']:
if genre in entity_genre[1]:
logger.info(f"Genre: {genre}")
return True, genre
- for i in wiki_parser['entities_info'][entity].get('instance of', []):
+ for i in entities_info[entity].get('instance of', []):
label = i[1]
if label == 'music genre' or label == 'genre':
for genre in genres:
@@ -372,7 +375,7 @@ def get_genre(vars):
return True, genre
elif label in {'music band', 'musical band', 'ensemble', 'musical group', 'artist', 'rock band'}:
for genre in genres:
- for entity_genre in wiki_parser['entities_info'][entity].get('genre', []):
+ for entity_genre in entities_info[entity].get('genre', []):
if genre in entity_genre[1]:
logger.info(f"Genre: {genre}")
return True, genre
