Pastebin is 300% more awesome when you are logged in. Sign Up, it's FREE!

Markov Chain (Pattern generation)

By: xxdriesxx on Jun 28th, 2011  |  syntax: C#  |  size: 0.49 KB  |  hits: 109  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. foreach (string s in dataSequence)
  2. {      
  3.         var vowels = new char[] { 'a', 'e', 'i', 'o', 'u' };
  4.         var consonants = new char[]
  5.         {
  6.                 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n', 'p', 'q', 'r', 's', 't', 'v',
  7.                 'w', 'x', 'y', 'z'
  8.         };
  9.  
  10.         var pattern = "";
  11.  
  12.         foreach (var character in name.ToLower())
  13.         {
  14.                 if (vowels.Contains(character))
  15.                         pattern += 'V';
  16.                 else if (consonants.Contains(character))
  17.                         pattern += 'C';
  18.                 else
  19.                         pattern += character;
  20.         }
  21.  
  22.         _patterns.Add(pattern);
  23. }