Пример #1
0
        /// <summary>
        /// serializes the indexes to files
        /// </summary>
        public void saveLists()
        {
            File.Delete(postingPath + @"\list1.bin");
            File.Delete(postingPath + @"\list2.bin");
            File.Delete(postingPath + @"\list3.bin");
            File.Delete(postingPath + @"\list4.bin");
            File.Delete(postingPath + @"\list5.bin");
            File.Delete(postingPath + @"\Doc.bin");
            IFormatter formatter = new BinaryFormatter();

            formatter.Serialize(new FileStream(postingPath + @"\list1.bin", FileMode.Create, FileAccess.Write, FileShare.None), mainIndexList1);
            formatter.Serialize(new FileStream(postingPath + @"\list2.bin", FileMode.Create, FileAccess.Write, FileShare.None), mainIndexList2);
            formatter.Serialize(new FileStream(postingPath + @"\list3.bin", FileMode.Create, FileAccess.Write, FileShare.None), mainIndexList3);
            formatter.Serialize(new FileStream(postingPath + @"\list4.bin", FileMode.Create, FileAccess.Write, FileShare.None), mainIndexList4);
            formatter.Serialize(new FileStream(postingPath + @"\list5.bin", FileMode.Create, FileAccess.Write, FileShare.None), mainIndexList5);
            formatter.Serialize(new FileStream(postingPath + @"\Doc.bin", FileMode.Create, FileAccess.Write, FileShare.None), Parse.d_docs);
            Parse.StopWords = ReadFile.readStopWords(postingPath + @"\stop_words.txt");
        }
Пример #2
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="PathData">path to data files</param>
 /// <param name="indexer">instance of indexer</param>
 /// <param name="stemming">yes/no stemming</param>
 public Parse(string PathData, string PathPosting, Indexer indexer, bool stemming)
 {
     d_abNumTerms = new SortedDictionary <string, Term>();
     d_cfTerms    = new SortedDictionary <string, Term>();
     d_gmTerms    = new SortedDictionary <string, Term>();
     d_nrTerms    = new SortedDictionary <string, Term>();
     d_szTerms    = new SortedDictionary <string, Term>();
     use_stem     = stemming;
     filesPath    = PathData;
     _indexer     = indexer;
     postingPath  = PathPosting;
     StopWords    = ReadFile.readStopWords(PathData + @"\stop_words.txt");
     if (!File.Exists(PathPosting + @"\stop_words.txt"))
     {
         File.Copy(PathData + @"\stop_words.txt", PathPosting + @"\stop_words.txt");
     }
     if (months.Count == 0)
     {
         addMonths();
     }
 }
Пример #3
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="postingPath">path to save the posting to</param>
        /// <param name="v">load posting from files</param>
        public Indexer(string postingPath, bool v)
        {
            this.postingPath = postingPath;
            IFormatter formatter = new BinaryFormatter();

            termsData = new Dictionary <string, double>();

            try
            {
                mainIndexList1  = (SortedList <string, int>)formatter.Deserialize(new FileStream(postingPath + @"\list1.bin", FileMode.Open, FileAccess.Read, FileShare.Read));
                mainIndexList2  = (SortedList <string, int>)formatter.Deserialize(new FileStream(postingPath + @"\list2.bin", FileMode.Open, FileAccess.Read, FileShare.Read));
                mainIndexList3  = (SortedList <string, int>)formatter.Deserialize(new FileStream(postingPath + @"\list3.bin", FileMode.Open, FileAccess.Read, FileShare.Read));
                mainIndexList4  = (SortedList <string, int>)formatter.Deserialize(new FileStream(postingPath + @"\list4.bin", FileMode.Open, FileAccess.Read, FileShare.Read));
                mainIndexList5  = (SortedList <string, int>)formatter.Deserialize(new FileStream(postingPath + @"\list5.bin", FileMode.Open, FileAccess.Read, FileShare.Read));
                Parse.d_docs    = (Dictionary <string, Doc>)formatter.Deserialize(new FileStream(postingPath + @"\Doc.bin", FileMode.Open, FileAccess.Read, FileShare.Read));
                Parse.StopWords = ReadFile.readStopWords(postingPath + @"\stop_words.txt");
            }
            catch (Exception e)
            {
                throw;
            }
        }