Created
December 20, 2019 23:26
-
-
Save Fleker/a3b9e7e6b03fa019256376b4ccc405f5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const setSessionEntities = (conv: Conv) => { | |
// Create sets for each type of entity type | |
const trackTitles = new Set<string>() | |
const trackGenres = new Set<string>() | |
const trackTags = new Set<string>() | |
conv.data.json.tracks.forEach(track => { | |
trackTitles.add(track.track_title) | |
track.track_genre.forEach(genre => { | |
trackGenres.add(genre) | |
}) | |
track.tags.forEach(tag => { | |
trackTags.add(tag) | |
}) | |
}) | |
conv.sessionEntities.add({ | |
name: 'track', | |
entities: Array.from(trackTitles).map(title => { | |
return { | |
value: title, | |
synonyms: [title] | |
} | |
}) | |
}) | |
conv.sessionEntities.add({ | |
name: 'genre', | |
entities: Array.from(trackGenres).map(genre => { | |
return { | |
value: genre, | |
synonyms: [genre] | |
} | |
}) | |
}) | |
conv.sessionEntities.add({ | |
name: 'tag', | |
entities: Array.from(trackTags).map(tag => { | |
return { | |
value: tag, | |
synonyms: [tag] | |
} | |
}) | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment