private static void CheckEachWordForPrefixes(string word, ref PrefixCounterTracker AnyPrefixCount) { int minimumPostfixLength = 1; for (int i = 1; i < word.Length - minimumPostfixLength; i++) { AnyPrefixCount.Increment(word.Substring(0, i + 1), word); } }
public static void CheckEachChar(string TargetText, out AlphaCounterTracker Letter_OccuranceCounts, out WordCounterTracker WordCount, out int CapitalizationCount, out PrefixCounterTracker AnyPrefixCount) { Letter_OccuranceCounts = new AlphaCounterTracker(); CapitalizationCount = 0; StringBuilder CurrentWord = new StringBuilder(); WordCount = new WordCounterTracker(); AnyPrefixCount = new PrefixCounterTracker(); foreach (char c in TargetText) { Letter_OccuranceCounts.Increment(c); if (Char.IsUpper(c)) { CapitalizationCount++; if (CurrentWord.Length > 0) { WordCount.Increment(CurrentWord.ToString()); CheckEachWordForPrefixes(CurrentWord.ToString(), ref AnyPrefixCount); CurrentWord.Clear(); } } CurrentWord.Append(c); } if (CurrentWord.Length > 0) { WordCount.Increment(CurrentWord.ToString()); CheckEachWordForPrefixes(CurrentWord.ToString(), ref AnyPrefixCount); CurrentWord.Clear(); } }