Skip to content

Commit

Permalink
syntaxe, suite.
Browse files Browse the repository at this point in the history
  • Loading branch information
Yves Ouvrard, alias Collatinus committed Mar 7, 2016
1 parent 29132f1 commit 00d7f98
Show file tree
Hide file tree
Showing 6 changed files with 95 additions and 15 deletions.
4 changes: 2 additions & 2 deletions bin/data/syntaxe.la
Expand Up @@ -19,8 +19,8 @@

id:accPrep
doc:complément prépositionnel à l'accusatif
super:$prepacc:
sub:n pr:acc
super:$prepacc::
sub::n pr:acc

id:cod
doc:complément d'objet direct
Expand Down
Binary file added collatinus.1.gz
Binary file not shown.
4 changes: 2 additions & 2 deletions collatinus.pro
Expand Up @@ -8,8 +8,8 @@ DEPENDPATH += .

qtHaveModule(printsupport): QT += printsupport
QT += widgets
QT += network
QT += svg
#QT += network
#QT += svg

CONFIG += release_binary

Expand Down
1 change: 1 addition & 0 deletions src/mainwindow.cpp
Expand Up @@ -1178,6 +1178,7 @@ void MainWindow::effaceRes()
if (dockVisible(dockLem)) textEditLem->clear();
if (dockVisible(dockFlex)) textBrowserFlex->clear();
if (dockVisible(dockScand)) textEditScand->clear();
if (dockVisible(dockSynt)) textBrowserSynt->clear();
}

/**
Expand Down
94 changes: 83 additions & 11 deletions src/syntaxe.cpp
Expand Up @@ -5,13 +5,6 @@

ElS::ElS(QString lin, RegleS *parent)
{
/*
QStringList _lemmes;
QStringList _pos;
QStringList _morphos;
*/
//super:v:ind subj
//ѕub:n pr:acc
_regle = parent;
QStringList ecl = lin.split(':', QString::KeepEmptyParts);
_pos = ecl.at(1).split(',');
Expand Down Expand Up @@ -79,13 +72,92 @@ Syntaxe::Syntaxe(QString t, Lemmat *parent)
fs.close ();
}

/*
QString Syntaxe::analyse (QString t, int p)
{
setText (t);
QString mot = motSous(p);
// analyse régressive
// analyse progressive
return mot;
// se placer à la fin du mot
while (p < t.length()-1 && t.at(p).isLetter()) ++p;
QString motCour = motSous(p);
QStringList ret;
ret<<"\n-----------------\nRecherche à partir de "+motCour+"\n";
MapLem maplem = _lemmatiseur->lemmatiseM(motCour, true);
// pour chaque lemme de motCour
foreach (Lemme *lem, maplem.keys())
{
_lemCour = lem->gr();
_posCour = lem->pos();
// pour chaque pos+morpho de motCour
foreach (SLem sl, maplem.value(lem))
{
_morphCour = sl.morpho;
int pr = p;
QString motS;
QChar chp = t.at(pr);
// recherche régressive
int incr = -1;
do
{
bool limiteP = false;
while (chp.isLetter())
{
pr += incr;
chp = t.at(pr);
}
// TODO changer l'algo pour extraire la
// chaîne entre deux mots, et
// l'analyser globalement
// - pour pouvoir tenir compte de
// ponctuations != limite de P ;
// - pour détecter une limite de
// phrase.
// aller jusqu'à la limite de mot
while (pr > 0 && pr < t.length()-1 && !t.at(pr+1).isLetter())
{
pr += incr;
chp = t.at(pr);
// détecter une limite de phrase
// deux lignes vides = limite de phrase
if ((pr==0 || pr==t.length())
|| (QString(".?!;:").contains(chp))
|| (chp == '\n' && t.at(pr+incr) == '\n'))
limiteP = true;
}
if (!limiteP)
{
motS = motSous(pr);
ret << "nouveau mot "+motS;
while (t.at(pr+incr).isLetter()) pr += incr;
}
else
{
ret << "limite de phrase";
// revenir à la position de motCour
pr = p+1;
incr += 2;
}
} while (incr < 3);
}
}
return ret.join('\n');
}
*/

QString Syntaxe::analyse (QString t, int p)
{
setText (t);
const QString ponct (".;!?");
// déterminer les limites de la phrase
int lg = p;
while (lg > 0 && (!ponct.contains(t.at(lg)))
&& (t.at(lg) != '\n' && t.at(lg-1) != '\n')) --lg;
int ld = p;
while ((ld < t.length()-1) && (!ponct.contains(t.at(ld)))
&& (t.at(ld) != '\n' && t.at(ld+1) != '\n')) ++ld;
QString phr = t.mid(lg, ld-lg);
phr = phr.simplified();
phr.replace('\n', ' ');
return phr;
}

QString Syntaxe::motSous(int p)
Expand Down
7 changes: 7 additions & 0 deletions src/syntaxe.h
Expand Up @@ -61,6 +61,8 @@ class RegleS: public QObject
QString _tr;
public:
RegleS (QStringList lignes);
bool estSub(QString m);
bool estSuper(QString m);
};

class Syntaxe: public QObject
Expand All @@ -72,6 +74,11 @@ class Syntaxe: public QObject
Lemmat *_lemmatiseur;
QList<RegleS*> _regles;
QString _texte;
// variables motCour
QString _motCour;
QString _lemCour;
QString _posCour;
QString _morphCour;
public:
Syntaxe (QString t, Lemmat *parent);
QString analyse(QString t, int p);
Expand Down

0 comments on commit 00d7f98

Please sign in to comment.