示例#1
0
        /// Builds the index...
        public int CreateIndex(string collectionPath, string indexPath)
        {
            // start timer...
            DateTime start = DateTime.Now;

            // get all of the files names in the collection path
            List <string> filenames = FileHandling.GetFileNames(collectionPath, false);

            // initialise the index
            InitIndex(indexPath);

            // build the index
            // this method call does lots of things in parallel
            myCollection = ReadAndProcessFiles(filenames);

            // close the index
            CleanUpIndex();

            // end timer and calculate total time
            DateTime end      = DateTime.Now;
            TimeSpan duration = end - start;

            indexTime = duration.Seconds + (float)duration.Milliseconds / 1000;

            return(myCollection.Length());
        }
示例#2
0
        /// Writes a trec evaluation file from the search results.
        /// if the query is not a standard one, '000' is used as the topicID
        public int WriteEvalFile(string fileName, string topicID)
        {
            List <string> evalList = new List <string>();

            bool appendFlag = true;

            // check if the file exists
            if (File.Exists(fileName) == true)
            {
                // prompt for append
                DialogResult append = MessageBox.Show("Do you want to append to the existing file?",
                                                      "Confirm",
                                                      MessageBoxButtons.YesNo);

                if (append == DialogResult.Yes)
                {
                    appendFlag = true;
                }
                else
                {
                    // if overwrite confirm
                    DialogResult ruSure = MessageBox.Show("Are you sure you want to overwrite the file?",
                                                          "Confirm",
                                                          MessageBoxButtons.YesNo);
                    if (ruSure == DialogResult.Yes)
                    {
                        appendFlag = false;
                    }
                }
            }

            // this is fixed
            string groupName = "09648500_NathanOnly";

            // structure TopicID QO DocID rank score group
            string tempString = "";

            for (int i = 0; i < resultsCollection.Length(); i++)
            {
                IRDocument doc = resultsCollection.GetIRDocument(i);
                tempString  = topicID + "\tQ0\t";
                tempString += doc.GetDocID() + "\t";
                tempString += doc.Rank + "\t";
                tempString += doc.Score + "\t";
                tempString += groupName + "\n";

                evalList.Add(tempString);
            }

            // write file
            FileHandling.WriteTextFile(evalList, fileName, appendFlag);

            return(0);
        }
示例#3
0
        /// Builds an IRCollection from the search results.
        //  This is used to display the search results.
        //  returns the number of results
        public int BuildResults()
        {
            CreateSearcher();

            IRCollection resultDocs = new IRCollection(myCollection, searcher, searchResults);

            CleanUpSearcher();

            resultsCollection = resultDocs;

            return(resultDocs.Length());
        }