I'm making out a couple of ideas to make an algorithm that would find 3 most common words in multiple sentences. What do I mean by that? Let's have a look at the example below, let's say I have 3 sentence like as follows:
1. New Samsung Galaxy S7 Edge SM-G935FD Duos 12MP 4G (FACTORY UNLOCKED) 32GB Phone
2. Samsung Galaxy S7 32GB G930P (GSM Unlocked) 4G LTE 12MP Smartphone Black A
3. New Samsung Galaxy S7 SM-G930FD Duos 5.1'' 12MP (FACTORY UNLOCKED) 32GB Phone
The algorithm determines that the 3 most commons words (all next to eachother) are: "Samsung galaxy S7".
My idea (I believe this is the most simplest one that can be implemented) is to take out the first 3 words from the first sentence and start out like that. So for example:
1st loop I get these 3 combinations of words: New Samsung Galaxy 2nd loop I get these 3 combinations of words (excluding the first word in the sentence): Samsung galaxy S7...
So on goes the process till the first sentence (string) ends.
Now my question to you guys is:
- Is this a good way to do like I mentioned above?
- Are there Algorithms out there that could do the same thing, but are more efficient when time factor comes in question (ie. they work faster)?
Can someone help me out with this? Thanks ! :)