Algorithm for finding three most common word arrays being repeated in multiple sentences
<p>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:</p>

<pre><code>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
</code></pre>

<p>The algorithm determines that the 3 most commons words (all next to eachother) are: "Samsung galaxy S7". </p>

<p>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:</p>

<p>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...</p>

<p>So on goes the process till the first sentence (string) ends. </p>

<p>Now my question to you guys is:</p>

<ol>
<li>Is this a good way to do like I mentioned above?</li>
<li>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)? </li>
</ol>

<p>Can someone help me out with this? Thanks ! :)</p>