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(); } }
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"); }
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); }
public Program() { DefaultIIndexableCollection<Course> UOfTCourses; DefaultIIndexableCollection<SchoolProgram> UOfTPrograms; IdSigner<Course> courseSigner = new IdSigner<Course>(); IdSigner<SchoolProgram> progSigner = new IdSigner<SchoolProgram>(); IItemFetcher<UTCourse> artsciCourseFetcher = new UTArtsciCourseFetcher(); IItemFetcher<UTCourse> engCourseFetcher = new UTEngCourseFetcher(); UOfTCourses = new DefaultIIndexableCollection<Course>("University of Toronto", "uoft_courses", courseSigner, artsciCourseFetcher.FetchItems().Concat<UTCourse>(engCourseFetcher.FetchItems())); UOfTCourses.Save(); IItemFetcher<SchoolProgram> artsciProgramFetcher = new UTArtsciProgramFetcher(); UOfTPrograms = new DefaultIIndexableCollection<SchoolProgram>("University of Toronto", "uoft_progs", progSigner, artsciProgramFetcher.FetchItems()); UOfTPrograms.Save(); }
public Program() { DefaultIIndexableCollection <Course> UOfTCourses; DefaultIIndexableCollection <SchoolProgram> UOfTPrograms; IdSigner <Course> courseSigner = new IdSigner <Course>(); IdSigner <SchoolProgram> progSigner = new IdSigner <SchoolProgram>(); UOfTCourses = new DefaultIIndexableCollection <Course>("University of Toronto", "uoft_courses", courseSigner, new UTEngCourseFetcher().FetchItems() //new UTArtsciCourseFetcher().FetchItems() //new UTSCCourseFetcher().FetchItems() .Concat <UTCourse>(new UTArtsciCourseFetcher().FetchItems()) .Concat <UTCourse>(new UTSCCourseFetcher().FetchItems()) .Concat <UTCourse>(new UTMCourseFetcher().FetchItems()) ); UOfTCourses.SaveBin(); UOfTPrograms = new DefaultIIndexableCollection <SchoolProgram>("University of Toronto", "uoft_progs", progSigner, new UTArtsciProgramFetcher().FetchItems() .Concat <SchoolProgram>(new UTEngProgramFetcher(WebUrlConstants.EngPrograms).FetchItems()) .Concat <SchoolProgram>(new UTSCProgramFetcher().FetchItems()) .Concat <SchoolProgram>(new UTMProgramFetcher().FetchItems())); UOfTPrograms.SaveBin(); }
public Program() { DefaultIIndexableCollection<Course> UOfTCourses; DefaultIIndexableCollection<SchoolProgram> UOfTPrograms; IdSigner<Course> courseSigner = new IdSigner<Course>(); IdSigner<SchoolProgram> progSigner = new IdSigner<SchoolProgram>(); IItemFetcher<UTCourse> artsciCourseFetcher = new UTArtsciCourseFetcher(); IItemFetcher<UTCourse> artsciSeminarFetcher = new UTArtsciSeminarFetcher(); IItemFetcher<UTCourse> engCourseFetcher = new UTEngCourseFetcher(); IItemFetcher<UTCourse> utscCourseFetcher = new UTSCCourseFetcher(); IItemFetcher<UTCourse> utmCourseFetcher = new UTMCourseFetcher(); UOfTCourses = new DefaultIIndexableCollection<Course>("University of Toronto", "uoft_courses", courseSigner, engCourseFetcher.FetchItems() //artsciCourseFetcher.FetchItems() //utscCourseFetcher.FetchItems() .Concat<UTCourse>(artsciCourseFetcher.FetchItems()) //.Concat<UTCourse>(artsciSeminarFetcher.FetchItems()) .Concat<UTCourse>(utscCourseFetcher.FetchItems()) .Concat<UTCourse>(utmCourseFetcher.FetchItems()) ); UOfTCourses.SaveBin(); IItemFetcher<SchoolProgram> artsciProgramFetcher = new UTArtsciProgramFetcher(); IItemFetcher<SchoolProgram> engProgramFetcher = new UTEngProgramFetcher(WebUrlConstants.EngPrograms); IItemFetcher<SchoolProgram> utscProgramFetcher = new UTSCProgramFetcher(); IItemFetcher<SchoolProgram> utmProgramFetcher = new UTMProgramFetcher(); UOfTPrograms = new DefaultIIndexableCollection<SchoolProgram>("University of Toronto", "uoft_progs", progSigner, artsciProgramFetcher.FetchItems() .Concat<SchoolProgram>(engProgramFetcher.FetchItems()) .Concat<SchoolProgram>(utscProgramFetcher.FetchItems()) .Concat<SchoolProgram>(utmProgramFetcher.FetchItems())); UOfTPrograms.SaveBin(); }
protected void Application_Start() { RouteTable.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); string path = Server.MapPath("Data"); this.UOfTCourses = DefaultIIndexableCollection<Course>.Read(Path.Combine(path, CoursesFileName)); this.CourseIndex = InvertedWordIndex.Read(Path.Combine(path, CoursesIndexFileName)); this.CoursePresenter = new CourseSearchPresenter(this.CourseIndex, this.UOfTCourses); this.UOfTPrograms = DefaultIIndexableCollection<SchoolProgram>.Read(Path.Combine(path, ProgramsFileName)); this.ProgramIndex = InvertedWordIndex.Read(Path.Combine(path, ProgramsIndexFileName)); this.ProgramPresenter = new ProgramSearchPresenter(this.ProgramIndex, this.UOfTPrograms); // Start a background thread to load and maintain the index, user map, and history this.StateThread = new Thread(new ThreadStart(MaintainState)); this.StateThread.Start(); }
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); }
public static void Index <T>(DefaultIIndexableCollection <T> school) where T : IIndexable { Indexer <T> indexer = new Indexer <T>(school.Abbr); indexer.Index(school.Items); }