We have a given list:
list_of_versions = ['apple II' ,'apple', 'apple 1' , 'HD APPLE','apple 3.5', 'adventures of apple' , 'apple III','orange 2' ,'300mhz apple', '300-orange II' , 'orange II HD' , 'orange II tvx', 'orange 2' , 'HD berry-vol 2', 'berry II', 'berry 2', 'berry VI', 'berry 1', 'berry II' ,'berry' ,'II Berry']
How can I find the main word of each string? For example:
word | main
--------------------------
apple II |apple
val/apple |apple
apple 1 |apple
HD APPLE |apple
apple 3.5 |apple
adventures of apple |apple
apple III |apple
300mhz apple |apple
orange 2 |orange
300-orange II |orange
orange II HD |orange
/orange/II-tvx |orange
orange 2 |orange
HD berry-vol 2 |berry
berry-II |berry
-berry-2 |berry
(berry) VI |berry
berry 1 |berry
berry II |berry
berry 2022 B8 |berry
II Berry-hd |berry
22 Berry II |berry
Berry 6.8.9 |berry
Important points:
I can not create the main word list which contains three main words (apple, orange, berry). Because the list will be updated with new main words. So we will never know what is the new words.
there is no limit to versions. At some point, we can see something like 'apple XII' or 'GB-HD berry 2.4' so version value can be everything. (in case you want to create a stopword list)
Nice to have (but it is not mandatory)--> Adding another column as well which shows the version. i.e:
word | main | version
-----------------------------------
apple II |apple | II
val/apple |apple | NULL
apple 1 |apple | 1
HD APPLE |apple | HD
apple 3.5 |apple | 3.5
apple III |apple | III
300mhz apple II |apple | II
orange 2 |orange | 2
300-orange II |orange | II
orange II HD |orange | II HD
/orange/II-tvx |orange | II tvx
orange 2 |orange | 2
HD berry-vol 2 |berry | 2 HD
berry-II |berry | II
-berry-2 |berry | 2
(berry) VI |berry | VI
berry 1 |berry | 1
berry II |berry | II
berry 2022 |berry | NULL
II Berry-hd |berry | II HD
22 Berry |berry | 22
Berry 6.8.9 |berry | 6.8.9