コード例 #1
0
        private static void Main(string[] args)
        {
            var wordIndex = new WordIndex();
            var readWords =
                ReadWords(new List <string>())
                .SelectMany(list => list.Where(s => s.Length > 3))
                .Take(10 * 1000 * 1000)
                .ToArray();
            int j1 = 0;

            foreach (var source in readWords.Take(10))
            {
                Console.WriteLine(j1++ + " " + source);
            }
            wordIndex.InsertPortion(readWords.Select((s, i) => new Tuple <int, string>(i, s.ToString())));
            Console.WriteLine(GC.GetTotalMemory(false) / 1024 / 1024);

            Console.WriteLine();
            foreach (var word in readWords.Skip(10).Take(10))
            {
                for (int j = 0; j < word.Length - 3; j++)
                {
                    string subWord = word.Substring(j);
                    var    res     = wordIndex.FindBySubWord(subWord).ToArray();
                    for (int i = 0; i < readWords.Length; i++)
                    {
                        if (res.Contains(i))
                        {
                            if (readWords[i].Contains(subWord))
                            {
                                continue;
                            }
                            else
                            {
                                Console.WriteLine(readWords[i]);
                            }
                        }
                        else
                        {
                            if (readWords[i].Contains(subWord))
                            {
                                throw new Exception("mising");
                            }
                        }
                    }
                }
            }
        }