vue-tags-input icon indicating copy to clipboard operation
vue-tags-input copied to clipboard

Does vue-tag-input support synonyms for tag suggestion?

Open rgranit opened this issue 6 years ago • 1 comments

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!

rgranit avatar Mar 19 '19 14:03 rgranit

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.

Assisting avatar May 01 '19 22:05 Assisting