I'm trying to create a unique name which includes all the data that could be found in an array of strings (names). It shouldn't repeat words.
Given this:
[
'Xiaomi Mi',
'Xiaomi',
'Mi',
'TV',
'Stick',
'Xiaomi Mi TV Stick',
'Xiaomi Mi TV',
'Mi TV Stick',
'Mi TV',
'TV Stick',
'Reproductor',
'Reproductor Multimedia',
'Multimedia'
]
I would like to get something like this:
'Xiaomi Mi TV Stick, Reproductor Multimedia'
I would like to analyze the data (natural language processing, maybe) and come up with a unique name, so the solution shouldn't be about taking the longest elements in the array, for example.
The simplest possible option would be
title = [...new Set(words.join(' ').split(' '))].join(' ')
which creates a long string from all array elements, splits that string into words, and concatenates unique words back.
If you want some "real" NLP, which would, for example, intelligently create "Xiaomi Mi Stick" from [Mi Stick Xiaomi], look around for a library. This is a complex problem that requires thousands lines of code.