Advertisement
Guest User

Untitled

a guest
Nov 19th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. public IDictionary<string, Index> CountWords(FullText fullText)
  2.         {
  3.             var wordCount = new Dictionary<string, Index>();
  4.  
  5.             foreach (Sentence sentence in fullText.text)
  6.             {
  7.                 foreach (Word word in sentence.Words)
  8.                 {
  9.             if(wordcount.ContainsKey(word.Value)) {
  10.                 wordcount[word.Value].WordCount++;
  11.             wordcount[word.Value].NumbersOfSentence++;
  12.             } else {
  13.             wordcount[word.Value] = new Index {
  14.                 WordCout = 1,
  15.                 NumbersOfSentence = 1,
  16.                 firstLetterOfWord = word.Value[0]      
  17.             }
  18.             }
  19.                                     }
  20.             }
  21.  
  22.             return wordCount;
  23.         }
  24.  
  25.  public class Index
  26.     {
  27.         public int WordCount { get; set; }
  28.         public int [] NumbersOfSentence { get; set; }
  29.         public char firstLetterOfWord { get; set; }
  30.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement