title: How can I predict patterns in user input?
body: <p>I am working on software in which the user may select multiple substrings from an arbitrary string. Sometimes, this will naturally result in patterns. E.g.:</p>
  
  <pre><code>"The quick brown fox jumps over the lazy dog"
   - substring selected: brown fox
  "The quick purple fox jumps over the lazy dog"
   - substring selected: purple fox
  "The quick orange fox jumps over the lazy dog"
   - substring selected: orange fox
  </code></pre>
  
  <p>So it would seem that the user is always selecting the characters "fox" and the word immediately preceding it.</p>
  
  <p>It would be really neat if I could implement some subroutine that could offer "Predictions" for these substrings, which the user could either make use of, or discard as appropriate. E.g.:</p>
  
  <pre><code>"The quick yellow fox jumps over the lazy dog"
   - suggested substring: yellow fox (ACCEPTED)
  "The quick red fox jumps over the lazy dog"
   - suggested substring: red fox (ACCEPTED)
  "The English Foxhound is a scent hound, bred to hunt foxes by scent."
   - suggested substring: hunt fox (REJECTED)
  </code></pre>
  
  <p>Generally speaking, how would one identify patterns in user input programatically, and use those patterns to make predictions about future input?</p>