Ejemplo n.º 1
0
 private static void getWord(SemanticValueDict Semantics, Slots slot, List<string> keywords)
 {
     if (Semantics.HasSlot(slot))
      {
     keywords.Add(Semantics.GetSlot(slot));
      }
 }
Ejemplo n.º 2
0
 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?");
      }
 }
Ejemplo n.º 3
0
 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?");
        }
     }
      }
 }
Ejemplo n.º 4
0
 public static List<Slots> ContainsCourseData(SemanticValueDict course)
 {
     if (DialogManager.Instance.CurrentCourse == null)
      {
     return SemanticsContainsCourseData(course);
      }
      return new List<Slots>();
 }
Ejemplo n.º 5
0
        private List<string> gatherWords(SemanticValueDict semantics)
        {
            List<string> keywords = new List<string>();

             getWord(semantics, Slots.KeyWords, keywords);
             //getWord(semantics, Slots.KeyWords2, keywords);

             return keywords;
        }
Ejemplo n.º 6
0
 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";
      }
 }
Ejemplo n.º 7
0
        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();
        }
Ejemplo n.º 8
0
        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;
        }
Ejemplo n.º 9
0
        /// <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;
        }
Ejemplo n.º 10
0
 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;
 }
Ejemplo n.º 11
0
 private void ProcessSupplemental(SemanticValueDict semantics)
 {
     SetContext(semantics);
      InformAndPerformCurrentAction(semantics);
 }
Ejemplo n.º 12
0
        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");
             }
        }
Ejemplo n.º 13
0
 private bool isJunkSpeech(SemanticValueDict semantics)
 {
     if (semantics.Count() == 1 && semantics.HasSlot(Slots.CourseAnaphora))
      {
     return true;
      }
      return false;
 }
Ejemplo n.º 14
0
 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;
 }
Ejemplo n.º 15
0
        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;
        }
Ejemplo n.º 16
0
        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);
            }
             }
        }
Ejemplo n.º 17
0
        public void notOffered(SemanticValueDict context, Semester semester)
        {
            //RecoManager.Instance.SayCancelAll();

             RecoManager.Instance.Say("That class is not available in the " + semester.ToString());
        }
Ejemplo n.º 18
0
        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;
        }
Ejemplo n.º 19
0
 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;
 }
Ejemplo n.º 20
0
 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;
      }
 }
Ejemplo n.º 21
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;
        }
Ejemplo n.º 22
0
 protected override void PromptForMissing(SemanticValueDict semantics, List<Slots> missing)
 {
 }