├── .gitignore
├── .gitmodules
├── images
└── svg
│ ├── license.txt
│ ├── abacus.svg
│ ├── dicolitt.svg
│ ├── noun_project_94-power.svg
│ ├── dicolem.svg
│ ├── help-browser.svg
│ ├── edit-alpha.svg
│ ├── system-search.svg
│ ├── document-new.svg
│ ├── edit-clear.svg
│ └── folder-open.svg
├── collatinus.qrc
├── collatinus.pro
├── src
├── maj.h
├── lewis.h
├── main.h
├── syntaxe.h
├── maj.cpp
├── libcollatinus.h
├── lewis.cpp
└── syntaxe.cpp
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | Makefile
2 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "ressources"]
2 | path = ressources
3 | url = https://github.com/biblissima/collatinus-data.git
4 |
--------------------------------------------------------------------------------
/images/svg/license.txt:
--------------------------------------------------------------------------------
1 | # the following are icon comming with this project are part of the tango
2 | # desktop project http://tango.freedesktop.org/ or derivate from it, and are
3 | # release to the public domain.
4 |
5 | document-new.svg
6 | document-open.svg
7 | document-save-as.svg
8 | document-save.svg
9 | edit-clear.svg
10 | edit-delete.svg
11 | edit-find-replace.svg
12 | edit-find.svg
13 | folder-open.svg
14 | folder-saved-search.svg
15 | help-browser.svg
16 | system-search.svg
17 |
18 | # those are derivate work
19 | Format-text-size-decrease.svg
20 | Format-text-size-incease.svg
21 |
22 | # this icon is derivative from the Noun Project
23 | # (http://www.thenounproject.com/)
24 | # and is in public domain
25 | noun_project_94-power.svg
26 |
27 | # those last 3 have been created for the project
28 | # (put license here)
29 | edit-alpha.svg
30 | gear.svg
31 | syntaxe.svg
32 |
--------------------------------------------------------------------------------
/collatinus.qrc:
--------------------------------------------------------------------------------
1 |
2 |
3 | images/svg/edit-alpha.svg
4 | images/svg/edit-clear.svg
5 | images/svg/noun_project_94-power.svg
6 | images/svg/edit-find.svg
7 | images/svg/Format-text-size-increase.svg
8 | images/svg/Format-text-size-decrease.svg
9 | images/svg/help-browser.svg
10 | images/svg/gear.svg
11 | images/svg/document-new.svg
12 | images/svg/document-open.svg
13 | images/svg/document-save-as.svg
14 | images/svg/syntaxe.svg
15 | images/svg/edit-clear.svg
16 | images/svg/document-new.svg
17 | images/svg/document-save.svg
18 | images/svg/edit-alpha.svg
19 | images/svg/edit-clear.svg
20 | images/svg/edit-delete.svg
21 | images/svg/edit-find-replace.svg
22 | images/svg/folder-open.svg
23 | images/svg/folder-saved-search.svg
24 | images/svg/system-search.svg
25 | images/svg/syntaxe.svg
26 | images/svg/gear.svg
27 | images/svg/Format-text-size-increase.svg
28 | images/svg/Format-text-size-decrease.svg
29 | images/svg/help-browser.svg
30 | images/svg/noun_project_94-power.svg
31 | images/svg/abacus.svg
32 | images/svg/dicolem.svg
33 | images/svg/dicolitt.svg
34 |
35 |
36 |
--------------------------------------------------------------------------------
/collatinus.pro:
--------------------------------------------------------------------------------
1 | ######################################################################
2 | # Automatically generated by qmake (2.01a) mer. nov. 1 14:52:27 2006
3 | # And modify manually
4 | ######################################################################
5 |
6 | TEMPLATE = app
7 | TARGET = collatinus
8 | VERSION = "10.2"
9 | DEFINES += VERSION=\\\"$$VERSION\\\"
10 | DEPENDPATH += .
11 | INCLUDEPATH += .
12 | # TRANSLATIONS = collatinus_en.ts collatinus_la.ts collatinus_fr.ts
13 |
14 | OBJECTS_DIR= obj/
15 | MOC_DIR = moc/
16 |
17 | # Input
18 | HEADERS += src/*.h
19 | FORMS += src/*.ui
20 | SOURCES += src/*.cpp #src/*.cc
21 | RESOURCES += collatinus.qrc
22 | QT += svg
23 | QT += xmlpatterns
24 | CONFIG += release_binary
25 |
26 | TRANSLATIONS = collatinus_fr.ts \
27 | collatinus_en.ts \
28 |
29 | macx{
30 | TARGET = Collatinus
31 | #note mac os x, fair un $ qmake -spec macx-g++
32 | #CONFIG += x86 ppc
33 | QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.6
34 | ICON = MacOS/collatinus.icns
35 | #QMAKE_MAC_SDK = /Developer/SDKs/MacOSX10.4u.sdk
36 |
37 | #QMAKE_POST_LINK=strip Collatinus.app/Contents/MacOS/collatinus
38 |
39 | # install into app bundle
40 | # à changer en ressources
41 | data.path = Collatinus.app/Contents/MacOS
42 | data.files = ressources/*
43 | deploy.depends = install_documentation
44 | deploy.depends += install
45 | documentation.path = Collatinus.app/Contents/MacOS/doc/
46 | documentation.files = doc/*.html doc/*.css
47 | # ajouter un cible qui fait macdeploy Collatinus.app
48 | deploy.commands = macdeployqt Collatinus.app
49 | dmg.depends = deploy
50 | dmg.commands = ./MacOS/Collatinus.sh
51 | INSTALLS += documentation
52 | # INSTALLS += data
53 | QMAKE_EXTRA_TARGETS += deploy
54 | QMAKE_EXTRA_TARGETS += dmg
55 | }
56 | unix:!macx{
57 | target.path = /usr/bin
58 | target.target = collatinus
59 | install.files = ressources/lemmata.* ressources/lucretia.txt ressources/expressions.fr
60 | install.path = /usr/share/collatinus9
61 | documentation.path = /usr/share/collatinus9/doc
62 | documentation.files = doc/*.html
63 |
64 | INSTALLS += target
65 | INSTALLS += install
66 | INSTALLS += documentation
67 | }
68 |
--------------------------------------------------------------------------------
/images/svg/abacus.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
65 |
--------------------------------------------------------------------------------
/src/maj.h:
--------------------------------------------------------------------------------
1 | /*
2 | * maj.h
3 | *
4 | * This file is part of COLLATINVS.
5 | *
6 | * COLLATINVS is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * COLLATINVS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with COLLATINVS; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | #ifndef MAJ_H
22 | #define MAJ_H
23 |
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 | #include
31 | #include
32 | #if QT_VERSION >= 0x050000 // Philippe travaille avec Qt5 sur Mac et a besoin de ces 3 lignes !!!
33 | #include
34 | #endif
35 |
36 | QString const urlDepot = "http://outils.biblissima.fr/collatinus/";
37 |
38 | typedef QList ListeF;
39 |
40 | class HttpWindow: public QDialog
41 | {
42 | Q_OBJECT
43 | public:
44 | HttpWindow (QWidget *parent = 0);
45 | void append(const QUrl &url);
46 | void append(const QStringList &urlList);
47 | QString saveFileName(const QUrl &url);
48 |
49 | signals:
50 | void finished();
51 |
52 | private slots:
53 | void startNextDownload();
54 | void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
55 | void downloadFinished();
56 | void downloadReadyRead();
57 | void telecharger ();
58 |
59 | private:
60 | void setupUi(QDialog *Dialog);
61 | // widgets
62 | QString depot;
63 | QVBoxLayout *verticalLayout;
64 | QLabel *urlLabel;
65 | QPushButton *boutonTelech;
66 | QDialogButtonBox *buttonBox;
67 | QLabel *label;
68 | QProgressDialog *progressDialog;
69 | // téléchargement
70 | QNetworkAccessManager manager;
71 | QQueue downloadQueue;
72 | QNetworkReply *currentDownload;
73 | QFile output;
74 | // QTime downloadTime;
75 | // variables
76 | QString repRes;
77 | QString repDic;
78 | bool finis;
79 | int downloadedCount;
80 | int totalCount;
81 | bool httpRequestAborted;
82 | // affichage des fichiers à télécharger
83 | QStringList suffIdxCfg;
84 | QStringList suffDic;
85 | ListeF ls (QString d); // établit la liste les fichiers locaux
86 | QList lcb; // liste des combos
87 | QStringList invis; // liste des satellites
88 | void peupleCombos ();
89 | };
90 |
91 | #endif
92 |
--------------------------------------------------------------------------------
/images/svg/dicolitt.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
81 |
--------------------------------------------------------------------------------
/src/lewis.h:
--------------------------------------------------------------------------------
1 | /* lewis.h
2 | *
3 | * This file is part of COLLATINVS.
4 | *
5 | * COLLATINVS 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 COLLATINVS; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | */
20 |
21 | #ifndef LEWIS_H
22 | #define LEWIS_H
23 | #include
24 |
25 | typedef QPair pairL;
26 | typedef QList llew;
27 |
28 | class Dictionnaire: public QObject
29 | {
30 | Q_OBJECT
31 |
32 | private:
33 | QString n; // nom
34 | QString repertoire;
35 | QString chData; // chemin complet du fichier djvu ou xml
36 | bool xml;
37 | bool djvu;
38 | QString auteur;
39 | QString url;
40 | int debut;
41 | QStringList idxDjvu;
42 | QString idxJv; // chemin de l'index jv
43 | QString cond_jv;
44 | bool ji;
45 | bool JI;
46 | bool xsl;
47 | QString prec; // pages précédente et suivante
48 | QString suiv;
49 | int pdj;
50 | bool jv;
51 | QStringList liens;
52 | QString ligneLiens;
53 | QString echelle; // échelle pour l'extraction d'une image d'un djvu
54 | public:
55 | Dictionnaire (QString cfg);
56 | QString nom ();
57 | void vide_index ();
58 | void vide_ligneLiens ();
59 | bool lis_index_djvu ();
60 | QString convert (QString source);
61 | QString entree_pos (qint64 pos);
62 | QString page (QStringList req, int no=0); // lien si la requête vient d'un hyperlien djvu
63 | QString pageXml (QStringList req);
64 | QString pageDjvu (int p);
65 | QString pageDjvu (QStringList req, int no=0); // surcharge avec calcul des no de page
66 | int noPageDjvu ();
67 | QString pgPrec ();
68 | QString pgSuiv ();
69 | bool estXml ();
70 | QString indexJv ();
71 | QString indexIu ();
72 | QStringList links (); // renvoie liens
73 | QString ramise (QString f);
74 | };
75 |
76 | class ListeDic: public QObject
77 | {
78 | Q_OBJECT
79 |
80 | private:
81 | QMultiMap liste;
82 | Dictionnaire * currens;
83 |
84 | public:
85 | Dictionnaire * dictionnaire_par_nom (QString nom);
86 | void ajoute (Dictionnaire *d);
87 | void change_courant (QString nom);
88 | Dictionnaire * courant ();
89 | // page renvoie le code html de la page
90 | // du dictionnaire courant
91 | // correspondant au lemme l.
92 | };
93 |
94 | #endif
95 |
96 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Collatinus
2 |
3 | Ce dépôt contient les sources de [Collatinus](http://outils.biblissima.fr/collatinus/), un logiciel libre et gratuit pour la **lemmatisation et l'analyse morphologique de textes latins**.
4 |
5 | Collatinus est développé par Yves Ouvrard et Philippe Verkerk.
6 |
7 | **Page de présentation et téléchargement sur le site Biblissima** : [http://outils.biblissima.fr/collatinus/](http://outils.biblissima.fr/collatinus/) (exécutables disponibles pour Mac OS, GNU/Linux et Windows).
8 |
9 | Collatinus existe aussi en **version web** :
10 | - Démo sur le site Biblissima : [http://outils.biblissima.fr/collatinus-web/](http://outils.biblissima.fr/collatinus-web)
11 | - Collatinus-web sur Github : [collatinus-web-daemon](https://github.com/biblissima/collatinus-web-daemon) et [collatinus-web-ui](https://github.com/biblissima/collatinus-web-ui)
12 |
13 | ### Principales fonctionnalités
14 |
15 | - lemmatisation de mots latins ou d'un texte latin entier,
16 | - traduction des lemmes grâce aux dictionnaires de latin incorporés dans l'application,
17 | - affichage des quantités (durée longue ou brève des syllabes) et des flexions (déclinaison ou conjugaison).
18 |
19 | ## Installation
20 |
21 | Collatinus a été écrit avec **Qt**. Le fichier du projet Qt, `collatinus.pro`, devra probablement être adapté à l'environnement local. Nous le donnons ici à titre d'exemple (peut-être même qu'il fonctionnera).
22 |
23 | ### Ajout des données
24 |
25 | Pour que le programme Collatinus fonctionne, il faut lui fournir des **fichiers de données**. Ces fichiers sont rangés dans un répertoire `ressources/` que l'on trouvera dans le dépôt Github [collatinus-data](https://github.com/biblissima/collatinus-data). Les fichiers volumineux des dictionnaires (*.xml ou *.djvu) ne sont pas inclus dans le dépôt : ils doivent être téléchargés directement depuis la page Collatinus du site Biblissima (section Téléchargements : http://outils.biblissima.fr/collatinus/#telechargements)
26 |
27 | Selon le système d'exploitation utilisé, le dossier `ressources/` devra être rangé à un endroit précis. Pour Windows et Linux, il doit se trouver au même niveau que l'exécutable. Pour Mac OSX, tout se passe dans le paquet `Collatinus.app` (ou tout autre nom que l'on souhaite lui donner) et le dossier `ressources/` doit être placé dans le répertoire `Contents/MacOS/` (à côté de l'exécutable ; cet emplacement n'est probablement pas conforme aux directives d'Apple, et pourrait être modifié dans une version ultérieure).
28 | Pour que ces données soient adaptées à la version bureau de Collatinus, il convient de créer, dans ce répertoire `ressources/`, un sous-répertoire `dicos/` dans lequel seront rangés les fichiers relatifs aux dictionnaires (*.cfg, *.idx, *.css et *.xsl) ainsi que les dictionnaires eux-mêmes.
29 |
30 | Le **manuel d'aide** de Collatinus est disponible dans le dépôt [collatinus-data](https://github.com/biblissima/collatinus-data) (voir le dossier `doc/`; celui-ci devra être laissé à sa place à côté du dossier `ressources/` pour être inclu dans le programme).
31 |
32 |
33 | ## Licence
34 |
35 | Ce programme est mis à disposition par Yves Ouvrard et Philippe Verkerk sous licence [GNU GPL v3](http://www.gnu.org/licenses/gpl.html).
36 |
37 | ## Crédits
38 |
39 | **Remerciements** : William Whitaker †, Jose Luis Redrejo, Georges Khaznadar, Matthias Bussonier, Gérard Jeanneau, Philippe Verkerk, Jean-Paul Woitrain, Philipp Roelli, Perseus Digital Library.
40 |
--------------------------------------------------------------------------------
/images/svg/noun_project_94-power.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/src/main.h:
--------------------------------------------------------------------------------
1 | /* main.h
2 | *
3 | * This file is part of COLLATINVS.
4 | *
5 | * COLLATINVS 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 along
16 | * with COLLATINVS; if not, write to the Free Software Foundation, Inc., 59
17 | * Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | */
19 |
20 | /**
21 | * BOGUES & AGENDA
22 | *
23 |
24 | - fichiers récents dans Settings.
25 | - esse + dat. omniprésent
26 | - conspectus : vérifier le Jeanneau, qui semble confondre in et e
27 | conspectu(m)
28 | - implémenter la lemmatisation de la sélection si la touche Maj est
29 | enfoncée, par exemple, ou la proposer dans un contextuel.
30 | *
31 | */
32 |
33 | #ifndef MAIN_H
34 | #define MAIN_H
35 |
36 | #include "ui_collatinus.h"
37 | #include
38 | #include
39 | #include
40 | #include
41 | #include "libcollatinus.h"
42 | #include "lewis.h"
43 | #include "maj.h" // mise à jour à partir du serveur distant
44 |
45 | class fenestra;
46 |
47 | class Editeur : public QTextEdit
48 | {
49 | Q_OBJECT
50 |
51 | private:
52 | TLexicum * lexicum;
53 | QStringList listek;
54 | QStringList listekr; // canons ramistes
55 | QStringList listekq;
56 | QString ponctPhr; // = "[\\.\\;\\:\\?\\!]";
57 | QRegExp sepPhr;
58 | fenestra * fen;
59 | bool scand; // armé si l'onglet Quantites est visible
60 | public:
61 | Editeur (QWidget *parent, const char *name, TLexicum * l, fenestra *f);
62 | QString motCourant (QTextCursor C);
63 | bool debPhr (QTextCursor C);
64 | QString lemmatiseTxt (bool alpha=0, bool cumVocibus = false);
65 | QString lemmatiseTxt_expr (bool alpha = false);
66 | int nbk (); // nombre de lemmes dans la listek
67 | QString kAt (int n); // lemme n° n dans la listek
68 | void purge();
69 | void videListek ();
70 | void setScand (bool s);
71 | bool scande ();
72 | protected:
73 | void mousePressEvent(QMouseEvent *event);
74 | void mouseMoveEvent (QMouseEvent *event);
75 | void mouseReleaseEvent (QMouseEvent *event);
76 | signals:
77 | void copie (QString, QString);
78 | public slots:
79 | void changeMajPert (bool m);
80 | QStringList req ();
81 | };
82 |
83 | class fenestra : public QMainWindow, private Ui::MainWindow
84 | {
85 | Q_OBJECT
86 |
87 | public:
88 | fenestra (QString url);
89 | virtual ~fenestra ();
90 | void flechis (Tentree * e);
91 | int editeurCourant ();
92 | QTextEdit * editeurRes ();
93 | private:
94 | void majDic ();
95 | Editeur * EditLatin;
96 | void createActions();
97 | QActionGroup * grCibles;
98 | QTranslator * translatorF;
99 | QTranslator * translatorE;
100 | TLexicum * lexicum;
101 | void clearModif ();
102 | void capsamInLatinum (const QString &fileName);
103 | bool capsaminDiscum (const QString &fileName);
104 | bool cautio ();
105 | QString repertoire;
106 | QString capsaIn; // nom du fichier chargé
107 | QString capsaEx; // nom fu fichier enregistré
108 | QString nomen; // nom sans chemin ni extension ni _L ni _Q.
109 | QString dernierT; // nom du fichier à enregistrer dans les préférences.
110 | void daFichierCourant (QString fileName);
111 | HttpWindow * httpWin;
112 | QString quaerendum;
113 | bool inuentum;
114 | bool licetMorpho;
115 | ListeDic listeD;
116 | bool idx_lu;
117 | void deest ();
118 | QString lang;
119 | QString ante, post;
120 |
121 | private slots:
122 | void auxilium ();
123 | void decollatino ();
124 | void calepin ();
125 | void lexica_addere_corrigere ();
126 | void inuenire ();
127 | void inuenire_denuo ();
128 | void legere ();
129 | void lemmatiseTout (bool alpha=false);
130 | void alpha ();
131 | void noua ();
132 | bool scribere ();
133 | bool scribereVt ();
134 | void setCible ();
135 | void vide_texte ();
136 | void change_syntaxe ();
137 | void change_morpho (bool m);
138 | void affiche_lien (QUrl url);
139 | void change_glossarium (QString nomDic);
140 | void ecris_prefs ();
141 | void lis_prefs (QString url="");
142 | QString langInterf ();
143 |
144 | public slots:
145 | void langue_interface ();
146 | void lemmataRadere ();
147 | void frequences ();
148 | void controleIcone (int o);
149 | void affiche_lemmes_dic (QStringList lk, int no=0);
150 | void affiche_lemme_saisie (bool litt=false);
151 | void affiche_lemme_saisie_litt ();
152 | void affiche_flexion_saisie ();
153 | void change_page_djvu (int p);
154 | void clicAnte ();
155 | void clicPost ();
156 | protected:
157 | bool event (QEvent *event);
158 | void closeEvent(QCloseEvent *event);
159 | };
160 |
161 | #endif
162 |
--------------------------------------------------------------------------------
/src/syntaxe.h:
--------------------------------------------------------------------------------
1 | /* syntaxe.h
2 | *
3 | * This file is part of PRAELECTOR.
4 | *
5 | * PRAELECTOR 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 | * PRAELECTOR 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 PRAELECTOR; if not, write to the Free Software
17 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 | *
19 | */
20 |
21 | /**
22 | TODO: transformer la recherche d'un canon ds la phrase :
23 | QSet Phrases::canons, alimenté par la liste morphos.
24 | TODO: ajouter la possibilité de plusieurs lemmes pour une position
25 | de l'expression, avec la même morpho
26 | ou même plusieurs lemmes pour la même position, avec des morphos
27 | différentes
28 | TODO:
29 | - le mot noyau est répété : alius... alius ;
30 | - la même expression est répétée dans la phrase.
31 | */
32 |
33 | #ifndef SYNTAXE_H
34 | #define SYNTAXE_H
35 | #include "libcollatinus.h"
36 | #include
37 | #include
38 | #include
39 | #include
40 | #include
41 |
42 | /*************************************************/
43 | // classes côté texte
44 | /*************************************************/
45 |
46 | class Morphos: public QObject
47 | {
48 | Q_OBJECT
49 | private:
50 | QString canon;
51 | QString graphie;
52 | QStringList elements;
53 | int item;
54 | public:
55 | Morphos (QString mo);
56 | virtual ~Morphos ();
57 | void setCanon (QString c);
58 | QString getCanon ();
59 | QString getGraphie ();
60 | QString humain ();
61 | QString cas ();
62 | QString genre ();
63 | QString nombre ();
64 | void setItem (int i);
65 | int getItem ();
66 | bool accepte (Morphos * mb);
67 | };
68 |
69 | typedef QList ListeM;
70 | class Mot: public QObject
71 | {
72 | Q_OBJECT
73 | private:
74 | TLexicum * lexicum;
75 | QString graphie;
76 | QString lemme;
77 | ListeM morphos;
78 | void lemmatise ();
79 | bool adopte;
80 | public:
81 | Mot (QString g, TLexicum * lx, bool debut = false);
82 | virtual ~Mot ();
83 | int no; // ordre du mot dans la phrase
84 | int count_morphos ();
85 | QString getGraphie ();
86 | QString getCanon (int i);
87 | QString get_lemme ();
88 | Morphos * getMorpho (int i);
89 | QString humain (int i);
90 | QString humain ();
91 | QString lemmatisation ();
92 | void setAdopte (bool a);
93 | bool estAdopte ();
94 | bool casCommun (Mot * m);
95 | bool nombreCommun (Mot * m);
96 | bool deb_phr;
97 | };
98 |
99 | /*************************************************/
100 | // CLASSES CÔTÉ BASE
101 | /*************************************************/
102 |
103 | class Canon
104 | {
105 | private:
106 | int id;
107 | QString graphie;
108 | public:
109 | Canon (QString g); // création par la graphie
110 | Canon (int i); // lecture à partir de la base
111 | };
112 |
113 | class Expression
114 | {
115 | private:
116 | QString nom;
117 | QString doc;
118 | QList morphos;
119 | int noyo; // pos dans l'expr du mot sous lequel elle s'affichera
120 | int posInP; // position du noyau dans la phrase
121 | int de;
122 | QString en;
123 | int avec;
124 | public:
125 | Expression (QString n); // créateur avec int id
126 | QString humain (); // notice affichée par Collatinus
127 | QString getNom ();
128 | QString getDoc ();
129 | QString getEn ();
130 | QString lemme_noyau ();
131 | int countMorphos ();
132 | int getPosInP ();
133 | void setPosInP (int p);
134 | Morphos * getMorpho (int im);
135 | bool accordVoulu ();
136 | };
137 |
138 | typedef QMultiMap L_expressions;
139 | class Liste_expr
140 | {
141 | private:
142 | L_expressions expressions;
143 | public:
144 | Liste_expr (QString f);
145 | ~Liste_expr ();
146 | QList expr_lemme (QString l);
147 | };
148 |
149 |
150 | // *************
151 | // CLASSE PHRASE
152 | // *************
153 |
154 | // phrase du texte préparée pour le
155 | // traitement fait par Requete
156 | class Phrase: public QObject
157 | {
158 | Q_OBJECT
159 | private:
160 | QString graphie;
161 | QList mots;
162 | QList liste_expressions;
163 | TLexicum * lexicum;
164 | void cherche_expressions ();
165 | int de;
166 | int avec;
167 | QString en;
168 | //bool requis_vus ();
169 | public:
170 | int debut;
171 | int fin; // début et fin pour repérage éventuel dans un texte.
172 | Phrase (QString t, TLexicum * l);
173 | virtual ~Phrase ();
174 | bool aiLeCanon (QString c);
175 | QList expressions ();
176 | Mot * mot_no (int n);
177 | Mot * motExpr (Morphos * m); // mot non adopté satisfaisant la morpho m
178 | Expression * expression_no (int n);
179 | bool accord (int de, QString en, int avec);
180 | QString analyse ();
181 | QStringList * analyse_et_lemmes ();
182 | void initAdoptes ();
183 | };
184 |
185 |
186 | // *************
187 | // CLASSE TEXTE
188 | // *************
189 |
190 | class Texte
191 | {
192 | private:
193 | QList phrases;
194 | public:
195 | Texte ();
196 | ~Texte ();
197 | void ajoute_phrase (Phrase * p);
198 | void vide_phrases ();
199 | bool phrase_at_pos (int p);
200 | Phrase * phrase_pos (int p);
201 | };
202 |
203 | void lis_expr (QString ch);
204 |
205 | void cree_texte ();
206 |
207 | void vide_phrases ();
208 |
209 | bool phrase_at_pos (int p);
210 |
211 | void cree_phrase (QString p, int d, int f, TLexicum * l);
212 |
213 | QString analyse_syntaxique (int p, int mot_no); //, QString &canon);
214 |
215 |
216 | #endif
217 |
--------------------------------------------------------------------------------
/images/svg/dicolem.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
131 |
--------------------------------------------------------------------------------
/src/maj.cpp:
--------------------------------------------------------------------------------
1 | /*
2 | * maj.cpp
3 | *
4 | * This file is part of COLLATINVS.
5 | *
6 | * COLLATINVS is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * COLLATINVS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with COLLATINVS; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | */
20 |
21 | #include "maj.h"
22 |
23 | #include
24 | #include
25 | #include
26 | #include
27 | #include
28 | #include
29 | #include
30 |
31 | HttpWindow::HttpWindow (QWidget *parent)
32 | : QDialog (parent)
33 | {
34 | progressDialog = new QProgressDialog (this);
35 | setupUi (this);
36 | // chemins
37 | repRes = qApp->applicationDirPath () + "/ressources/";
38 | repDic = repRes + "dicos/";
39 | // liste des extensions dictionnaire
40 | suffDic.clear (); // en cas de réouverture du dialogue
41 | invis.clear (); // idem
42 | suffIdxCfg << "idx" << "cfg" << "xsl" << "css";
43 | suffDic << "djvu" << "xml" << suffIdxCfg;
44 | // télécharger l'url du catalogue
45 | append (QStringList () << urlDepot + "url_depot.txt");
46 | while (!finis)
47 | {
48 | qApp->processEvents ();
49 | }
50 | QFile *fdepot = new QFile (repRes + "url_depot.txt");
51 | fdepot->open (QIODevice::ReadOnly|QIODevice::Text);
52 | QTextStream flux (fdepot);
53 | depot = flux.readAll ().trimmed ();
54 | fdepot->close ();
55 | delete fdepot;
56 | // télécharger le catalogue
57 | append (QStringList () << depot + "catalogue.txt");
58 | }
59 |
60 | void HttpWindow::setupUi (QDialog *Dialog)
61 | {
62 | Dialog->setObjectName (QString::fromUtf8 ("Collatinus - mise à jour"));
63 | setModal (true);
64 | verticalLayout = new QVBoxLayout (Dialog);
65 | label = new QLabel (Dialog);
66 | label->setText (tr ("Ajouter ou télécharger.\nIl faudra ensuite relancer Collatinus"));
67 | verticalLayout->addWidget (label);
68 | buttonBox = new QDialogButtonBox (Dialog);
69 | buttonBox->setOrientation (Qt::Horizontal);
70 | boutonTelech = new QPushButton (tr ("&Expromere"));
71 | buttonBox->addButton (boutonTelech, QDialogButtonBox::ActionRole);
72 | buttonBox->setStandardButtons (QDialogButtonBox::Close);
73 | verticalLayout->addWidget (buttonBox);
74 |
75 | QObject::connect (buttonBox, SIGNAL (rejected()), Dialog, SLOT (reject()));
76 | QObject::connect (boutonTelech, SIGNAL (clicked ()), Dialog, SLOT (telecharger ()));
77 | QMetaObject::connectSlotsByName (Dialog);
78 | }
79 |
80 | void HttpWindow::append (const QStringList &urlList)
81 | {
82 | foreach (QString url, urlList)
83 | {
84 | append (QUrl (url));
85 | finis = false;
86 | }
87 | if (downloadQueue.isEmpty())
88 | {
89 | QTimer::singleShot(0, this, SIGNAL(finished()));
90 | }
91 | }
92 |
93 | void HttpWindow::append(const QUrl &url)
94 | {
95 | if (downloadQueue.isEmpty())
96 | QTimer::singleShot(0, this, SLOT(startNextDownload()));
97 |
98 | downloadQueue.enqueue(url);
99 | ++totalCount;
100 | }
101 |
102 | QString HttpWindow::saveFileName(const QUrl &url)
103 | {
104 | // extraire le nom du fichier, et le chemin de
105 | // destination : ressources ou ressources/dicos.
106 | QString path = url.toString ();
107 | QString basename = path.section ('/', -1);
108 | if (basename.isEmpty())
109 | basename = "sine_nomine";
110 | if (suffDic.contains (QFileInfo (basename).suffix ()))
111 | basename.prepend (repDic);
112 | else basename.prepend (repRes);
113 | return basename;
114 | }
115 |
116 | void HttpWindow::startNextDownload()
117 | {
118 | if (downloadQueue.isEmpty())
119 | {
120 | emit finished();
121 | finis = true;
122 | peupleCombos ();
123 | return;
124 | }
125 | finis = false;
126 | progressDialog->show ();
127 | QUrl url = downloadQueue.dequeue ();
128 | QString filename = saveFileName (url);
129 | output.setFileName (filename);
130 | if (!output.open(QIODevice::WriteOnly))
131 | {
132 | fprintf(stderr, "Problème d'ouverture '%s' pour télécharger '%s': %s\n",
133 | qPrintable(filename), url.toEncoded().constData(),
134 | qPrintable(output.errorString()));
135 | startNextDownload();
136 | return; // skip this download
137 | }
138 | QNetworkRequest request(url);
139 | request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
140 | currentDownload = manager.get(request);
141 | connect(currentDownload, SIGNAL(downloadProgress(qint64,qint64)),
142 | SLOT(downloadProgress(qint64,qint64)));
143 | connect(currentDownload, SIGNAL(finished()),
144 | SLOT(downloadFinished()));
145 | connect(currentDownload, SIGNAL(readyRead()),
146 | SLOT(downloadReadyRead()));
147 | // prepare the output
148 | // printf("Downloading %s\n", url.toEncoded().constData());
149 | // downloadTime.start();
150 | }
151 |
152 | void HttpWindow::downloadProgress(qint64 bytesReceived, qint64 bytesTotal)
153 | {
154 | if (httpRequestAborted)
155 | return;
156 | progressDialog->setMaximum(bytesTotal);
157 | progressDialog->setValue(bytesReceived);
158 | }
159 |
160 | void HttpWindow::downloadFinished ()
161 | {
162 | progressDialog->hide ();
163 | output.close();
164 | if (currentDownload->error())
165 | {
166 | // download failed
167 | fprintf(stderr, "Failed: %s\n", qPrintable(currentDownload->errorString()));
168 | }
169 | currentDownload->deleteLater();
170 | startNextDownload();
171 | }
172 |
173 | ListeF HttpWindow::ls (QString d)
174 | {
175 | QDir dir (d);
176 | QFileInfoList infoList = dir.entryInfoList ();
177 | ListeF lf;
178 | foreach (QFileInfo fileInfo, infoList)
179 | {
180 | if (fileInfo.isDir ())
181 | continue;
182 | QString octets;
183 | octets.setNum (fileInfo.size ());
184 | lf << (QStringList () << fileInfo.fileName () << octets);
185 | }
186 | return lf;
187 | }
188 |
189 |
190 | void HttpWindow::downloadReadyRead()
191 | {
192 | output.write (currentDownload->readAll());
193 | }
194 |
195 | void HttpWindow::peupleCombos ()
196 | {
197 | QFile *fcatalogue = new QFile (repRes + "catalogue.txt");
198 | fcatalogue->open (QIODevice::ReadOnly|QIODevice::Text);
199 | QTextStream flux (fcatalogue);
200 | QString tout = flux.readAll ();
201 | fcatalogue->close ();
202 | delete fcatalogue;
203 |
204 | QStringList ll = tout.split ("\n");
205 | ListeF lfd; // liste distants
206 | foreach (QString l, ll)
207 | {
208 | if (l.length () > 4)
209 | {
210 | lfd << l.split (":");
211 | }
212 | }
213 | // vider les cases à cocher;
214 | foreach (QCheckBox *cb, lcb)
215 | {
216 | verticalLayout->removeWidget (cb);
217 | delete cb;
218 | }
219 | lcb.clear ();
220 |
221 | // établir la liste des fichiers locaux dans ./ressources/
222 | ListeF lfl; // liste locaux
223 | lfl << ls (repRes);
224 | lfl << ls (repDic);
225 | bool present = false;
226 | foreach (QStringList ld, lfd)
227 | {
228 | present = false;
229 | foreach (QStringList ll, lfl)
230 | {
231 | // comparaison des noms
232 | if (ld[0] == ll[0])
233 | {
234 | present = true;
235 | // comparaison des tailles
236 | if (ld[1] != ll[1])
237 | {
238 | // si le fichier est visible
239 | if (ld.count () > 2)
240 | {
241 | QCheckBox *cb = new QCheckBox ("Mettre à jour " + ld[2]);
242 | cb->setObjectName (ld[0]);
243 | verticalLayout->insertWidget (1, cb);
244 | lcb << cb;
245 | }
246 | else invis << ld[0];
247 | }
248 | }
249 | }
250 | if (!present)
251 | {
252 | // fichier distant absent en local
253 | if (ld.count () > 2)
254 | {
255 | QCheckBox *cb = new QCheckBox ("Ajouter " + ld[2]);
256 | cb->setObjectName (ld[0]);
257 | verticalLayout->insertWidget (1, cb);
258 | lcb << cb;
259 | }
260 | else invis << ld[0];
261 | }
262 | }
263 | }
264 |
265 | void HttpWindow::telecharger ()
266 | {
267 | QStringList liste;
268 | foreach (QCheckBox * cb, lcb)
269 | {
270 | if (cb->isChecked ())
271 | {
272 | QString nom = cb->objectName ();
273 | QFileInfo finfo (nom);
274 | QString suff = finfo.suffix ();
275 | // ajouter les satellites du dictionnaire
276 | if ((QStringList () << "djvu" << "xml").contains (suff))
277 | {
278 | foreach (QString f, invis)
279 | {
280 | QFileInfo finfo2 (f);
281 | if (finfo.baseName () == finfo2.baseName ()
282 | && suffIdxCfg.contains (finfo2.suffix ()))
283 | {
284 | liste << (depot+f);
285 | }
286 | }
287 | }
288 | liste << (depot + nom);
289 | }
290 | }
291 | append (liste);
292 | }
293 |
--------------------------------------------------------------------------------
/src/libcollatinus.h:
--------------------------------------------------------------------------------
1 | /*
2 | * libcollatinus.h
3 | *
4 | * This file is part of COLLATINVS.
5 | *
6 | * COLLATINVS is free software; you can redistribute it and/or modify
7 | * it under the terms of the GNU General Public License as published by
8 | * the Free Software Foundation; either version 2 of the License, or
9 | * (at your option) any later version.
10 | *
11 | * COLLATINVS is distributed in the hope that it will be useful,
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 | * GNU General Public License for more details.
15 | *
16 | * You should have received a copy of the GNU General Public License
17 | * along with COLLATINVS; if not, write to the Free Software
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 | *
20 | */
21 |
22 | #ifndef LIBCOLLATINUS_H
23 | #define LIBCOLLATINUS_H
24 |
25 | #include