Skip to content

Commit

Permalink
Marquer les voyelles communes #26
Browse files Browse the repository at this point in the history
Les voyelles qui ne portent pas de quantité dans les lexiques sont explicitement marquées comme communes (macron+breve).
Corrigé aussi un pb dans le dénombrement des formes d'un texte. "lm" étant une liste obtenue par
    QStringList lm = t.split(QRegExp("\\b"));
le nombre de mots qu'elle contient est ((lm.count() - 1) / 2) et pas lm.count().
  • Loading branch information
PhVerkerk authored Jun 11, 2016
1 parent 58b139d commit 36be86d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 6 deletions.
21 changes: 21 additions & 0 deletions src/ch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,27 @@ QString Ch::atone(QString a, bool bdc)
return a;
}

/**
* \fn Ch:communes(QString g)
* \brief note comme communes toutes les voyelles qui ne portent pas de quantité.
*/
QString Ch::communes(QString g)
{
bool maj = g[0].isUpper();
g = g.toLower();
if (g.contains("a") || g.contains("e") || g.contains("i") || g.contains("o") || g.contains("u") || g.contains("y"))
{
g.replace("a","ā̆");
g.replace("[^āăō]e","ē̆");
g.replace("i","ī̆");
g.replace("o","ō̆");
g.replace("[^āēq]u","ū̆");
g.replace("[^ā]y","ȳ̆");
}
if (maj) g[0] = g[0].toUpper();
return g;
}

/**
* \fn Ch::deQuant(QString *c)
* \brief utilisée en cas d'élision.
Expand Down
1 change: 1 addition & 0 deletions src/ch.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ QChar const separSyll = 0x02CC;
QString transforme(QString k);
QString accentue(QString l);
QString ajoutSuff(QString fq, QString suffixe, QString l_etym, int accent);
QString communes(QString g);
}
#endif
4 changes: 2 additions & 2 deletions src/lemmatiseur.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -673,8 +673,8 @@ QString Lemmat::lemmatiseT(QString t, bool alpha, bool cumVocibus,
if (alpha) qSort(nonReconnus.begin(), nonReconnus.end(), Ch::sort_i);
QString titreNR;
QTextStream(&titreNR) << "--- " << nonReconnus.count() << "/"
<< lm.count() << " ("
<< ((nonReconnus.count() * 100) / lm.count())
<< (lm.count() - 1) / 2 << " ("
<< ((nonReconnus.count() * 200) / (lm.count()-1))
<< " %) FORMES NON RECONNUES ---" << nl << "\n";
lRet.append(titreNR + nl);
foreach (QString nr, nonReconnus)
Expand Down
18 changes: 14 additions & 4 deletions src/lemme.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ int Radical::numRad() { return _numero; }
* \brief Constructeur de la classe Lemme à partire de la
* ligne linea. *parent est le lemmatiseur (classe Lemmat).
*/
Lemme::Lemme(QString linea, QObject *parent)
Lemme::Lemme(QString linea, int origin, QObject *parent)
{
// cădo|lego|cĕcĭd|cās|is, ere, cecidi, casum
// 0 1 2 3 4
Expand All @@ -89,20 +89,21 @@ Lemme::Lemme(QString linea, QObject *parent)
_cle = Ch::atone(Ch::deramise(lg.at(0)));
_grd = oteNh(lg.at(0), _nh);
if (lg.count() == 1)
_grq = _grd;
_grq = Ch::communes(_grd);
else
_grq = lg.at(1);
_grq = Ch::communes(lg.at(1));
_gr = Ch::atone(_grq);
_grModele = eclats.at(1);
_modele = _lemmatiseur->modele(_grModele);
_hyphen = "";
_origin = origin;
// lecture des radicaux, champs 2 et 3
for (int i = 2; i < 4; ++i)
if (!eclats.at(i).isEmpty())
{
QStringList lrad = eclats.at(i).split(',');
foreach (QString rad, lrad)
_radicaux.insert(i - 1, new Radical(rad, i - 1, this));
_radicaux.insert(i - 1, new Radical(Ch::communes(rad), i - 1, this));
}
_lemmatiseur->ajRadicaux(this);

Expand Down Expand Up @@ -363,3 +364,12 @@ QString Lemme::getHyphen()
{
return _hyphen;
}

/**
* @brief Lemme::getOrigin()
* @return l'origine du lemme (lexique de base ou extension)
*/
int Lemme::getOrigin()
{
return _origin;
}

0 comments on commit 36be86d

Please sign in to comment.