2
0

WordIndex.cs 943 B

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