• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdeedu
  • Sitemap
  • Contact Us
 

parley

answervalidator.h

Go to the documentation of this file.
00001 /***************************************************************************
00002     Copyright 2007 Frederik Gladhorn <frederik.gladhorn@kdemail.net>
00003     Copyright 2008 David Capel <wot.narg@gmail.com>
00004  ***************************************************************************/
00005 
00006 /***************************************************************************
00007  *                                                                         *
00008  *   This program is free software; you can redistribute it and/or modify  *
00009  *   it under the terms of the GNU General Public License as published by  *
00010  *   the Free Software Foundation; either version 2 of the License, or     *
00011  *   (at your option) any later version.                                   *
00012  *                                                                         *
00013  ***************************************************************************/
00014 #ifndef ANSWERVALIDATOR_H
00015 #define ANSWERVALIDATOR_H
00016 
00017 #include <QtCore/QString>
00018 #include <QtCore/QPair>
00019 #include <QColor>
00020 
00021 #include "statistics/statistics.h"
00022 
00023 class KEduVocDocument;
00024 
00025 namespace Sonnet
00026 {
00027 
00028 class Speller;
00029 }
00030 
00031 
00038 class AnswerValidator : public QObject
00039 {
00040            Q_OBJECT
00041 
00042 
00043     public:
00044         AnswerValidator(KEduVocDocument* doc, QObject* parent = 0);
00045 
00046         ~AnswerValidator();
00047 
00052         void setLanguage(int translation);
00053 
00054         bool spellcheckerAvailable();
00055 
00056 
00057     public slots:
00058         void slotSetExpression(KEduVocExpression*);
00064         void slotCheckAnswer(const QString& solution, const QString& userAnswer);
00066         void slotCheckAnswer(const QStringList& solutions, const QStringList& userAnswers);
00067     signals:
00072         void signalCorrection(float, Statistics::ErrorType, const QString&);
00075         void signalFeedback(const QString& htmlfeedback);
00076     private:
00080         void defaultCorrector();
00081 
00085         void simpleCorrector();
00086 
00095         int levenshteinDistance(const QString& s, const QString& t);
00096 
00097         bool spellcheckerMisspelled(const QString& s);
00098 
00099         bool spellcheckerInSuggestionList(const QString& solution, const QString& userAnswer);
00100 
00108         void wordCompare(const QString& solution, const QString& userWord, double& grade, Statistics::ErrorType& errorType, QString& htmlCorrection);
00109 
00113         void sentenceAnalysis();
00114 
00121         QList< QPair < QString, QString > > bestPairs(const QStringList& solutionWords , const QStringList& userAnswerWords);
00122 
00124         KEduVocDocument* m_doc;
00125 
00127         KEduVocExpression* m_entry;
00128         int m_translation;
00129 
00131         QString m_solution;
00132 
00134         QString m_userAnswer;
00135 
00137         QByteArray m_d;
00138 
00140         Sonnet::Speller* m_speller;
00141         bool m_spellerAvailable;
00142 
00143         static const double LEVENSHTEIN_THRESHOLD;
00144         static const double UNRELATED_WORD_GRADE;
00145         static const double FALSE_FRIEND_GRADE;
00146         static const double SPELLING_MISTAKE_PER_LETTER_PUNISHMENT;
00147         static const double ACCENT_MISTAKE_PUNISHMENT;
00148         static const double CAPITALIZATION_MISTAKE_PUNISHMENT;
00149         static const double WRONG_ARTICLE_PUNISHMENT;
00150 };
00151 
00152 #endif

parley

Skip menu "parley"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdeedu

Skip menu "kdeedu"
  • kalzium
  • kanagram
  • kig
  •   lib
  • klettres
  • kstars
  • libkdeedu
  •   keduvocdocument
  •   docs
  •   src
  • parley
  •   stepcore
Generated for kdeedu by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal