diff options
Diffstat (limited to 'MediaBrowser.Tests/ConsistencyTests/TextIndexing')
4 files changed, 0 insertions, 119 deletions
diff --git a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/IndexBuilder.cs b/MediaBrowser.Tests/ConsistencyTests/TextIndexing/IndexBuilder.cs deleted file mode 100644 index 4c46f4793..000000000 --- a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/IndexBuilder.cs +++ /dev/null @@ -1,52 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; - -namespace MediaBrowser.Tests.ConsistencyTests.TextIndexing -{ - public class IndexBuilder - { - public const int MinumumWordLength = 4; - - public static char[] WordChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890".ToCharArray(); - - public static WordIndex BuildIndexFromFiles(IEnumerable<FileInfo> wordFiles, string rootFolderPath) - { - var index = new WordIndex(); - - var wordSeparators = Enumerable.Range(32, 127).Select(e => Convert.ToChar(e)).Where(c => !WordChars.Contains(c)).ToArray(); - wordSeparators = wordSeparators.Concat(new[] { '\t' }).ToArray(); // add tab - - foreach (var file in wordFiles) - { - var lineNumber = 1; - var displayFileName = file.FullName.Replace(rootFolderPath, string.Empty); - using (var reader = file.OpenText()) - { - while (!reader.EndOfStream) - { - var words = reader - .ReadLine() - .Split(wordSeparators, StringSplitOptions.RemoveEmptyEntries); - ////.Select(f => f.Trim()); - - var wordIndex = 1; - foreach (var word in words) - { - if (word.Length >= MinumumWordLength) - { - index.AddWordOccurrence(word, displayFileName, file.FullName, lineNumber, wordIndex++); - } - } - - lineNumber++; - } - } - } - - return index; - } - - } -} diff --git a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordIndex.cs b/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordIndex.cs deleted file mode 100644 index e0af08792..000000000 --- a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordIndex.cs +++ /dev/null @@ -1,36 +0,0 @@ -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; - } - - } -} diff --git a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordOccurrence.cs b/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordOccurrence.cs deleted file mode 100644 index b30e58624..000000000 --- a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordOccurrence.cs +++ /dev/null @@ -1,18 +0,0 @@ -namespace MediaBrowser.Tests.ConsistencyTests.TextIndexing -{ - public struct WordOccurrence - { - public readonly string FileName; // file containing the word. - public readonly string FullPath; // file containing the word. - public readonly int LineNumber; // line within the file. - public readonly int WordIndex; // index within the line. - - public WordOccurrence(string fileName, string fullPath, int lineNumber, int wordIndex) - { - FileName = fileName; - FullPath = fullPath; - LineNumber = lineNumber; - WordIndex = wordIndex; - } - } -} diff --git a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordOccurrences.cs b/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordOccurrences.cs deleted file mode 100644 index a6388ab54..000000000 --- a/MediaBrowser.Tests/ConsistencyTests/TextIndexing/WordOccurrences.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System.Collections.Generic; - -namespace MediaBrowser.Tests.ConsistencyTests.TextIndexing -{ - public class WordOccurrences : List<WordOccurrence> - { - public void AddOccurrence(string fileName, string fullPath, int lineNumber, int wordIndex) - { - this.Add(new WordOccurrence(fileName, fullPath, lineNumber, wordIndex)); - } - - } -} |
