vue-tags-input
vue-tags-input copied to clipboard
Does vue-tag-input support synonyms for tag suggestion?
Hello,
Looks like an amazing piece of software. Can one adapt the code to support synonyms for suggesting keywords?
Example selectedTags: [ 'big', 'small' ] list of synonyms:
big = ['large', 'huge', 'enormous'] small = ['little', 'tiny', 'minute'] So when the user will search for 'large' the tag 'big' will be suggested.
Thanks!
This is definitely possible. The autocomplete-items attribute can point to literally any computed property. For instance, I'm currently using the following filter:
return this.validTags.filter(i => {
return i.text.toLowerCase().indexOf(this.tag.toLowerCase()) !== -1;
});
But it could easily just be something like this:
var filteredTags = this.validTags.filter(i => {
return i.text.toLowerCase().indexOf(this.tag.toLowerCase()) !== -1;
});
return filteredTags.concat( getAllSynonymsOf( filteredTags ) )
...where getAllSynonymsOf() is some function to iterate over the list of suggestions and return all the lists of the all the synonyms for those suggestions.