parley
answervalidatorold.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef ANSWERVALIDATOROLD_H
00014 #define ANSWERVALIDATOROLD_H
00015
00016 #include "testentry.h"
00017
00018 #include <QtCore/QString>
00019 #include <QtCore/QPair>
00020
00021 class KEduVocDocument;
00022 namespace Sonnet {
00023 class Speller;
00024 }
00025
00031 class AnswerValidatorOld{
00032 public:
00033 AnswerValidatorOld(KEduVocDocument* doc);
00034
00035 ~AnswerValidatorOld();
00036
00037 bool spellcheckerAvailable();
00038
00043 void setTestEntry(TestEntry* entry);
00044
00049 void setLanguage(int translation);
00050
00057 void checkUserAnswer(const QString& userAnswer);
00058 void checkUserAnswer(const QString& solution, const QString& userAnswer, const QString& language = QString());
00059
00060 private:
00064 void defaultCorrector();
00065
00069 void simpleCorrector();
00070
00079 int levenshteinDistance(const QString& s, const QString& t);
00080
00081 bool spellcheckerMisspelled(const QString& s);
00082
00083 bool spellcheckerInSuggestionList(const QString& solution, const QString& userAnswer);
00084
00092 void wordCompare(const QString& solution, const QString& userWord, double& grade, TestEntry::ErrorTypes& errorTypes);
00093
00097 void sentenceAnalysis();
00098
00105 QList< QPair < QString, QString > > bestPairs(const QStringList& solutionWords , const QStringList& userAnswerWords );
00106
00108 KEduVocDocument* m_doc;
00109
00111 TestEntry* m_entry;
00112 int m_translation;
00113
00115 QString m_solution;
00116
00118 QString m_userAnswer;
00119
00121 QByteArray m_d;
00122
00124 Sonnet::Speller* m_speller;
00125 bool m_spellerAvailable;
00126
00127 static const double LEVENSHTEIN_THRESHOLD;
00128 static const double UNRELATED_WORD_GRADE;
00129 static const double FALSE_FRIEND_GRADE;
00130 static const double SPELLING_MISTAKE_PER_LETTER_PUNISHMENT;
00131 static const double ACCENT_MISTAKE_PUNISHMENT;
00132 static const double CAPITALIZATION_MISTAKE_PUNISHMENT;
00133 static const double WRONG_ARTICLE_PUNISHMENT;
00134 };
00135
00136 #endif