private static void getWord(SemanticValueDict Semantics, Slots slot, List<string> keywords) { if (Semantics.HasSlot(slot)) { keywords.Add(Semantics.GetSlot(slot)); } }
protected override void PromptForMissing(SemanticValueDict semantics, List<Slots> missing) { if (missing.Contains(Slots.Department) || missing.Contains(Slots.Number)) { RecoManager.Instance.Say("What course are you trying to remove?"); } }
protected virtual void PromptForMissing(SemanticValueDict semantics, List<Slots> missing) { if (missing.Count == 4) { RecoManager.Instance.Say("What would you like to take?"); } else { if (missing.Contains(Slots.Semester) || missing.Contains(Slots.Year)) { RecoManager.Instance.Say("When would you like to take this course?"); } if (missing.Contains(Slots.Department)) { if (missing.Contains(Slots.Number)) { RecoManager.Instance.Say("Which course was that?"); } else { RecoManager.Instance.Say("What department is this course in?"); } } } }
public static List<Slots> ContainsCourseData(SemanticValueDict course) { if (DialogManager.Instance.CurrentCourse == null) { return SemanticsContainsCourseData(course); } return new List<Slots>(); }
private List<string> gatherWords(SemanticValueDict semantics) { List<string> keywords = new List<string>(); getWord(semantics, Slots.KeyWords, keywords); //getWord(semantics, Slots.KeyWords2, keywords); return keywords; }
public static String MakeCourseNameForSpeech(SemanticValueDict semantics) { if (semantics.ContainsKey(Slots.Department.ToString()) && semantics.ContainsKey(Slots.Number.ToString())) { String dept = String.Join(" ", semantics.GetSlot(Slots.Department).ToCharArray()); String number = semantics.GetSlot(Slots.Number); return dept + " " + number; } else { return "this"; } }
public bool Inform(SemanticValueDict sem, Student student) { Student = student; if (Semantics == null) { Semantics = sem; } else { foreach (KeyValuePair<String, SemanticValueDict> pair in sem) { Semantics[pair.Key] = pair.Value; } } return ValidateCurrentData(); }
public static List<Slots> ContainsScheduledCourseData(SemanticValueDict course, bool ignoreSemester = false) { List<Slots> missing = ContainsCourseData(course); if (!ignoreSemester) { if (!course.ContainsKey(Slots.Semester.ToString()) && !DialogManager.Instance.CurrentSemester.HasValue) { missing.Add(Slots.Semester); } if (!course.ContainsKey(Slots.Year.ToString()) && !DialogManager.Instance.CurrentYear.HasValue) { missing.Add(Slots.Year); } } return missing; }
/// <summary> /// Contructs the scheduled course, will get the year and semester from the ActionManager /// if they are not part of the semantic value /// </summary> /// <param name="semantics">The semantics.</param> /// <returns></returns> public static ScheduledCourse ContructScheduledCourse(SemanticValueDict semantics) { Course course = ContructCourse(semantics); if (course == null) { return null; } Semester? sem = GetSemester(semantics, DialogManager.Instance.CurrentSemester); int? year = GetYear(semantics, DialogManager.Instance.CurrentYear); if (year == null) throw new InvalidOperationException("Should not be call without valid year information"); if (sem == null) throw new InvalidOperationException("Should not be called without semester information"); ScheduledCourse sCourse = new ScheduledCourse(course, sem.Value, year.Value); return sCourse; }
public static Course ContructCourse(SemanticValueDict semantics) { if (semantics.HasSlot(Slots.CourseName)) { String courseName = semantics.GetSlot(Slots.CourseName); Course course = CourseCatalog.Instance.Courses.Find(c => c.ToString().Equals(courseName)); return course; } else if (semantics.HasSlot(Slots.Department) && semantics.HasSlot(Slots.Number)) { String Department = semantics[Slots.Department.ToString()].Value.ToString(); int Number = (int)semantics[Slots.Number.ToString()].Value; IFilter<Course> filter = CourseFilter.DeptAbv(Department).And(CourseFilter.Number(Number, Operator.EQ)); return CourseCatalog.Instance.GetCourses(filter).FirstOrDefault(); } else if (DialogManager.Instance.CurrentCourse != null) { return DialogManager.Instance.CurrentCourse; } return null; }
private void ProcessSupplemental(SemanticValueDict semantics) { SetContext(semantics); InformAndPerformCurrentAction(semantics); }
private void ProcessCommand(SemanticValueDict semantics) { CommandTypes cmd = (CommandTypes)(semantics[Slots.Command.ToString()].Value); bool callEvent = false; SetContext(semantics); switch (cmd) { case CommandTypes.Bookmark: case CommandTypes.Add: case CommandTypes.Remove: case CommandTypes.Move: case CommandTypes.SetSemester: case CommandTypes.Inquire: case CommandTypes.Search: case CommandTypes.View: case CommandTypes.Save: case CommandTypes.Load: callEvent = doCourseRegistrationAction(semantics, cmd); break; case CommandTypes.Undo: callEvent = doUndoComnmand(callEvent); break; case CommandTypes.Help: IAction action = cmd.GetAction(); if (action != null) action.Perform(); beHelpful(); break; case CommandTypes.CloseWindow: CloseCommand(); break; case CommandTypes.Swap: case CommandTypes.Show: default: throw new ArgumentException("Invalid command type: " + cmd); } if (callEvent && actionDetected != null) { ActionDetectedEventArgs args = new ActionDetectedEventArgs(cmd, CurrStudent); actionDetected(this, args); RecoManager.Instance.Say("Ok"); } }
private bool isJunkSpeech(SemanticValueDict semantics) { if (semantics.Count() == 1 && semantics.HasSlot(Slots.CourseAnaphora)) { return true; } return false; }
private bool InformAndPerformCurrentAction(SemanticValueDict semantics) { bool callEvent = false; if (currentWorkingAction == null) { currentWorkingAction = new UnknownAction(); } callEvent = currentWorkingAction.Inform(semantics, CurrStudent); if (callEvent) { callEvent = currentWorkingAction.Perform(); //don't push events that didn't work if (callEvent) { actionHistory.Push(currentWorkingAction); currentWorkingAction.GiveConfirmation(); currentWorkingAction = null; } } return callEvent; }
private bool doCourseRegistrationAction(SemanticValueDict semantics, CommandTypes cmd) { bool callEvent = false; IAction action = cmd.GetAction(); if (currentWorkingAction == null || !currentWorkingAction.GetType().Equals(action.GetType())) { currentWorkingAction = action; } else if (currentWorkingAction.GetType().Equals(action.GetType()) || currentWorkingAction is UnknownAction) { action.Inform(currentWorkingAction.Semantics, CurrStudent); currentWorkingAction = action; } callEvent = InformAndPerformCurrentAction(semantics); return callEvent; }
public void SetContext(SemanticValueDict semantics) { Semester? semester = CourseConstructor.GetSemester(semantics); if (semester.HasValue) CurrentSemester = semester.Value; int? year = CourseConstructor.GetYear(semantics); if (year.HasValue) CurrentYear = year.Value; if (semester.HasValue && !year.HasValue) { if (semester == Semester.Fall) { CurrentYear--; } else { CurrentYear++; } } if (semester.HasValue || year.HasValue) OnSemesterChanged(); if (CourseConstructor.SemanticsContainsCourseData(semantics).Count == 0) { CurrentCourse = CourseConstructor.ContructCourse(semantics); if (CurrentCourse != null) { SetInfoPane(CurrentCourse.DeptAbv + CurrentCourse.Number + "\n" + CurrentCourse.Description); } } }
public void notOffered(SemanticValueDict context, Semester semester) { //RecoManager.Instance.SayCancelAll(); RecoManager.Instance.Say("That class is not available in the " + semester.ToString()); }
public static int? GetYear(SemanticValueDict semantics, int? year = null) { if (semantics.ContainsKey(Slots.Year.ToString())) year = int.Parse(semantics[Slots.Year.ToString()].Value.ToString()); return year; }
public static List<Slots> SemanticsContainsCourseData(SemanticValueDict course) { List<Slots> missing = new List<Slots>(); if (!course.HasSlot(Slots.CourseName)) { if (!course.ContainsKey(Slots.Department.ToString())) { missing.Add(Slots.Department); } if (!course.ContainsKey(Slots.Number.ToString())) { missing.Add(Slots.Number); } } return missing; }
internal static bool IsCourseDataValid(SemanticValueDict semantics) { if (semantics.HasSlot(Slots.CourseName)) { return true; } else { String dept = semantics.GetSlot(Slots.Department); String num = semantics.GetSlot(Slots.Number); IEnumerable<Course> courses = CourseCatalog.Instance.Courses.Where(c => c.Dept.Abv.Equals(dept) && c.Number.Equals(int.Parse(num))); return courses.Count() > 0; } }
public static Semester? GetSemester(SemanticValueDict semantics, Semester? sem = null) { if (semantics.ContainsKey(Slots.Semester.ToString())) { sem = (Semester)Enum.Parse(typeof(Semester), semantics[Slots.Semester.ToString()].Value.ToString(), true); } return sem; }
protected override void PromptForMissing(SemanticValueDict semantics, List<Slots> missing) { }