aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordIndex.cs
blob: e0af08792dbf321338f63a761ba6e93ebf2163d3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System;
using System.Collections.Generic;

namespace MediaBrowser.Tests.ConsistencyTests.TextIndexing
{
    public class WordIndex : Dictionary<string, WordOccurrences>
    {
        public WordIndex() : base(StringComparer.InvariantCultureIgnoreCase)
        {
        }

        public void AddWordOccurrence(string word, string fileName, string fullPath, int lineNumber, int wordIndex)
        {
            WordOccurrences current;
            if (!this.TryGetValue(word, out current))
            {
                current = new WordOccurrences();
                this[word] = current;
            }

            current.AddOccurrence(fileName, fullPath, lineNumber, wordIndex);
        }

        public WordOccurrences Find(string word)
        {
           WordOccurrences found;
           if (this.TryGetValue(word, out found))
           {
               return found;
           }

           return null;
        }

    }
}