Beispiel #1
0
        public void buildTrie()
        {
            PerformanceCounter memProcess = new PerformanceCounter("Memory", "Available MBytes");

            myTrie = new Trie();

            StreamReader titleReader = new StreamReader(HostingEnvironment.ApplicationPhysicalPath + "\\titles.txt");
            int          count       = 0;
            string       currLine    = titleReader.ReadLine();

            while (currLine != null)
            {
                count++;
                if (count % 10000 == 0)
                {
                    if (memProcess.NextValue() < 500)
                    {
                        break;
                    }
                }
                currLine = titleReader.ReadLine();
                if (Regex.IsMatch(currLine, @"^[a-zA-Z_]+$"))
                {
                    currLine = currLine.Replace('_', ' ');
                    myTrie.AddTitle(currLine);
                    trieSize++;
                    lastTrieEntry = currLine;
                }
            }
        }
        public string BuildTrie()
        {
            string line1;

            using (StreamReader reader = new StreamReader(filenameForBlob))
            {
                line1 = reader.ReadLine();
                Console.WriteLine(line1);
                PerformanceCounter availableRam = new PerformanceCounter("Memory", "Available MBytes");
                int count = 0;
                while (line1 != null && (Convert.ToInt32(availableRam.NextValue()) > 300))
                {
                    Debug.WriteLine(line1);
                    trie.AddTitle(line1);
                    availableRam = new PerformanceCounter("Memory", "Available MBytes");
                    line1        = reader.ReadLine();
                    count++;
                }
                return(count + "titles loaded");
            }
        }
Beispiel #3
0
        public string BuildTrie()
        {
            wikiTrie = new Trie();
            string line = "";

            using (StreamReader sr = new StreamReader(wikiFileStream))
            {
                float availableMBytes = GetAvailableMBytes();
                int   iter            = 0;
                while (sr.EndOfStream == false && availableMBytes > 20)
                {
                    line = sr.ReadLine();
                    wikiTrie.AddTitle(line);
                    if (iter % 10000 == 0)
                    {
                        availableMBytes = GetAvailableMBytes();
                    }
                    iter++;
                }
            }
            return("Trie built. Last title in trie: [" + line + "]");
        }