| 1 | /* lemmatiseur.h |
| 2 | * |
| 3 | * This file is part of COLLATINUS. |
| 4 | * |
| 5 | * COLLATINUS is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License as published by |
| 7 | * the Free Software Foundation; either version 2 of the License, or |
| 8 | * (at your option) any later version. |
| 9 | * |
| 10 | * COLLATINVS is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License |
| 16 | * along with COLLATINUS; if not, write to the Free Software |
| 17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 18 | * |
| 19 | * © Yves Ouvrard, 2009 - 2016 |
| 20 | */ |
| 21 | |
| 22 | #ifndef LEMMATISEUR_H |
| 23 | #define LEMMATISEUR_H |
| 24 | |
| 25 | #include <QMap> |
| 26 | #include <QString> |
| 27 | #include <QStringList> |
| 28 | #include <QtCore/QCoreApplication> |
| 29 | |
| 30 | #include "irregs.h" |
| 31 | #include "lemme.h" |
| 32 | #include "modele.h" |
| 33 | |
| 34 | class Irreg; |
| 35 | class Lemme; |
| 36 | class Radical; |
| 37 | |
| 38 | typedef struct |
| 39 | { |
| 40 | QString grq; |
| 41 | Lemme* lemme; |
| 42 | QString morpho; |
| 43 | QString sufq; |
| 44 | char pos; |
| 45 | } SLem; |
| 46 | |
| 47 | typedef QMap<Lemme*, QList<SLem> > MapLem; |
| 48 | |
| 49 | typedef QPair<QRegExp, QString> Reglep; |
| 50 | |
| 51 | class Lemmat : public QObject |
| 52 | { |
| 53 | Q_OBJECT |
| 54 | |
| 55 | private: |
| 56 | // fonction d'initialisation |
| 57 | void ajAssims(); |
| 58 | void ajContractions(); |
| 59 | void ajPos(); |
| 60 | int aRomano (QString r); |
| 61 | bool estRomain(QString r); |
| 62 | void lisIrreguliers(); |
| 63 | void lisLexicoSyntaxe(); |
| 64 | void lisLexique(); |
| 65 | void lisModeles(); |
| 66 | void lisTraductions(bool base, bool extension); |
| 67 | void posCf(); |
| 68 | // variables et utils |
| 69 | QMap<QString, QString> assims; |
| 70 | QMap<QString, QString> assimsq; |
| 71 | QStringList cherchePieds(int nbr, QString ligne, int i, bool pentam); |
| 72 | QMap<QString, QString> _contractions; |
| 73 | QMultiMap<QString, Desinence *> _desinences; |
| 74 | QStringList formeq(QString forme, bool *nonTrouve, bool debPhr, int accent = 0); |
| 75 | QMultiMap<QString, Irreg *> _irregs; |
| 76 | QString _cible; |
| 77 | QMap<QString, QString> _cibles; |
| 78 | QMap<QString, Lemme *> _lemmes; |
| 79 | QMap<QString, QChar> mapPos; |
| 80 | QMap<QString, Modele *> _modeles; |
| 81 | QStringList _morphos; |
| 82 | QMultiMap<QString, Radical *> _radicaux; |
| 83 | QList<Reglep> _reglesp; |
| 84 | QString _resDir; |
| 85 | QMap<QString, QString> _variables; |
| 86 | // options |
| 87 | bool _alpha; |
| 88 | bool _extension; // = false; |
| 89 | bool _extLoaded; |
| 90 | bool _formeT; |
| 91 | bool _html; |
| 92 | bool _majPert; |
| 93 | bool _morpho; |
| 94 | bool _nonRec; |
| 95 | |
| 96 | public: |
| 97 | Lemmat(QObject *parent = 0, QString resDir=""); |
| 98 | void ajDesinence(Desinence *d); |
| 99 | void ajModele(Modele *m); |
| 100 | void ajRadicaux(Lemme *l); |
| 101 | QString assim(QString a); |
| 102 | QString assimq(QString a); |
| 103 | QMap<QString, QString> cibles(); |
| 104 | QString desassim(QString a); |
| 105 | QString desassimq(QString a); |
| 106 | static QString deramise(QString r); |
| 107 | QStringList frequences(QString txt); |
| 108 | MapLem lemmatise(QString f); // lemmatise une forme |
| 109 | QStringList lemmatiseF(QString f, bool deb); |
| 110 | MapLem lemmatiseM(QString f, bool debPhr = true); |
| 111 | Lemme *lemme(QString l); |
| 112 | QStringList lignesFichier(QString nf); |
| 113 | void lisFichierLexique(QString filepath); |
| 114 | Modele *modele(QString m); |
| 115 | QString morpho(int i); |
| 116 | QChar posChar(QString p); |
| 117 | QString posString(QChar p); |
| 118 | QString scandeTxt(QString texte, int accent = 0, bool stats = false); |
| 119 | QMap<QString, QString> suffixes; |
| 120 | QString variable(QString v); |
| 121 | }; |
| 122 | |
| 123 | #endif |