WordIndex.cs 1014 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MediaBrowser.Tests.ConsistencyTests.TextIndexing
  7. {
  8. public class WordIndex : Dictionary<string, WordOccurrences>
  9. {
  10. public WordIndex() : base(StringComparer.InvariantCultureIgnoreCase)
  11. {
  12. }
  13. public void AddWordOccurrence(string word, string fileName, string fullPath, int lineNumber, int wordIndex)
  14. {
  15. WordOccurrences current;
  16. if (!this.TryGetValue(word, out current))
  17. {
  18. current = new WordOccurrences();
  19. this[word] = current;
  20. }
  21. current.AddOccurrence(fileName, fullPath, lineNumber, wordIndex);
  22. }
  23. public WordOccurrences Find(string word)
  24. {
  25. WordOccurrences found;
  26. if (this.TryGetValue(word, out found))
  27. {
  28. return found;
  29. }
  30. return null;
  31. }
  32. }
  33. }