title: longest common sequence group
body: <p>Given the following lines of text</p>
  
  <pre><code>TOKYO-BLING.1 H02-AVAILABLE
  TOKYO-BLING.1 H02-MIDDLING
  TOKYO-BLING.1 H02-TOP
  TOKYO-BLING.2 H04-USED
  TOKYO-BLING.2 H04-AVAILABLE
  TOKYO-BLING.2 H04-CANCELLED
  WAY-VERING.1 H03-TOP
  WAY-VERING.2 H03-USED
  WAY-VERING.2 H03-AVAILABLE
  WAY-VERING.1 H03-CANCELLED
  </code></pre>
  
  <p>I would like to do some parsing to generate somewhat sensible groupings. The list above can be grouped as follows</p>
  
  <pre><code>TOKYO-BLING.1 H02-AVAILABLE
  TOKYO-BLING.1 H02-MIDDLING
  TOKYO-BLING.1 H02-TOP
  
  TOKYO-BLING.2 H04-USED
  TOKYO-BLING.2 H04-AVAILABLE
  TOKYO-BLING.2 H04-CANCELLED
  
  WAY-VERING.2 H03-USED
  WAY-VERING.2 H03-AVAILABLE
  
  WAY-VERING.1 H03-TOP
  WAY-VERING.1 H03-CANCELLED
  </code></pre>
  
  <p>Can anyone suggest an algorithm(or some method) that can scan through a given amount of text and work out that the text can be grouped as above. Obviously each group can be further. I guess i am looking for a good solution to looking at a list of phrases and working out how best to group them by some common string sequence.</p>