Advertisement
xxdriesxx

Markov Chain Ruleset Building

Jun 23rd, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.51 KB | None | 0 0
  1. foreach (string s in dataSequence)
  2. {
  3.     int rest = data.Length%stepSize;
  4.  
  5.     for (int i = 0; i < data.Length - rest; i += stepSize)
  6.     {
  7.         string first = data.Substring(i, stepSize);
  8.         string followedBy = "";
  9.  
  10.         if (i == data.Length - (rest + stepSize))
  11.             followedBy = data.Substring(i + stepSize, rest);
  12.         else
  13.             followedBy = data.Substring(i + stepSize, stepSize);
  14.  
  15.         if (!_rules.ContainsKey(first))
  16.         {
  17.             _rules.Add(first, new List<string>());
  18.                 }
  19.  
  20.         _rules[first].Add(followedBy);
  21.     }
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement