예제 #1
0
        public static void Main(string[] args)
        {
            string            abbr  = args.Length > 0 ? args[0] : "uoft_courses";
            InvertedWordIndex index = InvertedWordIndex.Read(abbr + ".idx");
            DefaultIIndexableCollection <Course> school = DefaultIIndexableCollection <Course> .ReadBin(abbr + ".bin");

            CourseSearchPresenter searchEngine = new CourseSearchPresenter(index, school);

            while (true)
            {
                Console.Write("Please input a query: ");
                string             query  = Console.ReadLine();
                CourseSearchResult result = searchEngine.GetItemList(query) as CourseSearchResult;
                Console.WriteLine(result.CodeNameMatches);
                //CourseSearchResult result = searchEngine.GetCourseList(query);

                //if (result.CodeNameMatches.Count > 0)
                //{
                //    Console.WriteLine("\nCourse:");
                //    Console.WriteLine(result.CodeNameMatches.First<Course>().ToString());
                //}
                //foreach (IIndexable item in result.RawMatches)
                //{
                //    Course course = item as Course;
                //    Console.WriteLine("{0}: {1}", course.Abbr, course.Name);
                //}
                //if (result.RawMatches.Count > 0) Console.WriteLine("\nRelevant:");
                //foreach (IIndexable item in result.RawMatches)
                //{
                //    Course course = item as Course;
                //    Console.WriteLine("{0}: {1}", course.Abbr, course.Name);
                //}
                //Console.WriteLine();
            }
        }
예제 #2
0
        public static void Main(string[] args)
        {
            DefaultIIndexableCollection <Course>        school;
            DefaultIIndexableCollection <SchoolProgram> pschool;
            string cpath = args.Length > 0 ? args[0] : UTCoursesSavePath;
            string ppath = args.Length > 1 ? args[1] : UTProgramsSavePath;

            if (File.Exists(cpath) && File.Exists(ppath))
            {
                school = DefaultIIndexableCollection <Course> .ReadBin(cpath);

                pschool = DefaultIIndexableCollection <SchoolProgram> .ReadBin(ppath);

                Task indexTask = Task.Run(() =>
                {
                    Index <Course>(school);
                    Index <SchoolProgram>(pschool);
                });
                while (indexTask.Status == TaskStatus.Running)
                {
                    Console.WriteLine("Running...");
                    Thread.Sleep(1000);
                }
                indexTask.Wait();
            }
            else
            {
                throw new FileNotFoundException("Data file not found");
            }

            Console.WriteLine("Finished indexing");
        }
예제 #3
0
        protected void ReadData(string path)
        {
            this.UOfTCourses = DefaultIIndexableCollection <Course> .ReadBin(Path.Combine(path, CoursesFileName));

            this.CourseIndex     = InvertedWordIndex.Read(Path.Combine(path, CoursesIndexFileName));
            this.CoursePresenter = new CourseSearchPresenter(this.CourseIndex, this.UOfTCourses);

            this.UOfTPrograms = DefaultIIndexableCollection <SchoolProgram> .ReadBin(Path.Combine(path, ProgramsFileName));

            this.ProgramIndex     = InvertedWordIndex.Read(Path.Combine(path, ProgramsIndexFileName));
            this.ProgramPresenter = new ProgramSearchPresenter(this.ProgramIndex, this.UOfTPrograms);
        }