Пример #1
0
        internal void initializeObject()
        {
            SubQqestion1 = new SubQuestion();
            SubQqestion1.questionText = "הצג כיצד הסתיימה מלחמת העצמאות ואילו בעיות נותרו בלתי פתורות בעקבותיה.";
            SubQqestion1.answerText   = "בעיית הפליטים - כ500 אלף ערבים עזבו את בתיהם והפכו לפליטים. רובם לא קיבלו אזרחות במדינות אליהם ברחו והם שואפים לחזור לבתיהם - זכות השיבה | ירושליים נותרה מחולקת בשלטון הירדנים;";
            SubQqestion1.flags        = "needAll";

            userAnswerSubQuestion1 = "ירושלים נותרה מחולקת, והרבה ערבים נותרו כפליטים במדינות השכנות";

            WordObject1.Text   = "ערבים";
            WordObject1.Lemma  = "ערבי";
            WordObject1.WordT  = WordObject.WordType.organizationWord;
            WordObject1.Gender = genderType.masculine;
            WordObject1.Amount = amountType.plural;


            WordGufObjectThey        = new WordObject();
            WordGufObjectThey.WordT  = WordObject.WordType.gufWord;
            WordGufObjectThey.Gender = genderType.masculine;
            WordGufObjectThey.Amount = amountType.plural;


            Entity1.entityValue = "ערבי";
            Entity1.entityType  = "organizationWord";

            WordObject2.Text   = "ירושלים";
            WordObject2.WordT  = WordObject.WordType.locationWord;
            WordObject2.Amount = amountType.singular;
            WordObject2.Gender = genderType.feminine;

            Entity2.entityValue = "ירושלים";
            Entity2.entityType  = "locationWord";

            WordObject3.Text   = "פליטים";
            WordObject3.WordT  = WordObject.WordType.conceptWord;
            WordObject3.Gender = genderType.masculine;
            WordObject3.Amount = amountType.plural;

            Entity3.entityValue = "פליטים";
            Entity3.entityType  = "personWord";

            WordObject4.Text   = "ירדן";
            WordObject4.WordT  = WordObject.WordType.organizationWord;
            WordObject4.Gender = genderType.feminine;

            Entity4.entityValue = "ירדן";
            Entity4.entityType  = "locationWord";

            multyEntity.entityValue = "בעיית הפליטים";
            multyEntity.entityType  = "conceptWord";


            Question1.QuestionID = "1";
            Question2.QuestionID = "2";
            Question3.QuestionID = "3";
        }
        public AnswerFeedback checkAnswer(string text)
        {
            ISubQuestion question = studySession.CurrentSubQuestion;

            var answerFeedback = Qac.matchAnswers(question, text);

            try
            {
                Logger.addAnswerOutput(question.answerText, text, answerFeedback, user.UserID, question.questionID + "." + question.subQuestionID);
            }
            catch (Exception ex) { }

            return(answerFeedback);
        }
Пример #3
0
        public AnswerFeedback matchAnswers(ISubQuestion subquestion, string answer)
        {
            if (subquestion != null && answer != null)
            {
                var questionAnlize = new List <WorldObject>();
                if (subquestion.questionText != null)
                {
                    questionAnlize = Nlp.Analize(subquestion.questionText); //TODO : fix double computing
                }
                var            userAnswer = Nlp.Analize(answer, subquestion.questionText);
                AnswerFeedback feedback   = new AnswerFeedback();
                feedback.answer = answer;
                if (subquestion.answerText.Contains("|"))
                {
                    foreach (var ans in subquestion.answerText.Split('|'))
                    {
                        if (ans.Trim() != "")
                        {
                            var systemAnswerWords = Nlp.Analize(ans).Except(questionAnlize);
                            var f = matchAnswers(userAnswer, systemAnswerWords.ToList(), ans);
                            feedback.addFeedback(f);
                        }
                    }

                    var feedbacks = feedback.answersFeedbacks;

                    if (feedbacks.Count == 0)
                    {
                        throw new Exception(subquestion.answerText);
                    }

                    var flags = subquestion.flags;



                    if (flags == null || flags.Trim() == "" || flags.Trim() == "needAll")
                    {
                        feedback.Need  = feedback.answersFeedbacks.Count;
                        feedback.score = (int)feedback.answersFeedbacks.Average(x => x.score);
                    }
                    else
                    {
                        int numberInt;

                        var numberStr = flags.Replace("need", "");
                        int.TryParse(numberStr, out numberInt);
                        numberInt     = numberInt == 0 ? feedbacks.Count : numberInt;
                        feedback.Need = numberInt;
                        feedbacks.Sort((x, y) => y.score - x.score);
                        feedbacks = feedbacks.GetRange(0, numberInt);
                        foreach (var f in feedbacks)
                        {
                            feedback.score = (int)feedbacks.Average(x => x.score);
                        }
                        //feedback.answersFeedbacks = feedbacks;
                    }
                }
                else
                {
                    var systemAnswer = Nlp.Analize(subquestion.answerText).Except(questionAnlize);
                    var f            = matchAnswers(userAnswer, systemAnswer.ToList());
                    f.answer = subquestion.answerText;
                    feedback.addFeedback(f);
                    feedback.Need = 1;
                }


                if (feedback == null)
                {
                    feedback = new AnswerFeedback();
                }



                return(feedback);
            }
            else
            {
                return(new AnswerFeedback());
            }
        }
 public AnswerFeedback matchAnswers(ISubQuestion subquestion, string answer)
 {
     return(qna.matchAnswers(subquestion, answer));
 }