- std::string conjFileName, verbsFileName;
- FrenchVerbDictionary::getXMLFilenames(conjFileName, verbsFileName, lang);
- */
- freVerbDic = new FrenchVerbDictionary(false);
- const std::string word = input.toUtf8().constData();
- templateSet = &freVerbDic->getVerbTemplateSet(word);
- for (std::set<std::string>::const_iterator it = templateSet->begin();
- it != templateSet->end(); ++it)
- {
- const std::string &tname = *it;
-
- FrenchVerbDictionary::getRadical(word, tname);
- }
+ * For each possible deconjugation, take the infinitive form and
+ * obtain its complete conjugation.
+ */
+ std::vector<InflectionDesc> infles;
+ bool includePronouns = FALSE; // TODO: Will get this value from external
+ bool isItalian = FALSE; // TODO: Will get this value from external
+
+#ifndef QT_NO_DEBUG
+ timer.start();
+ qDebug() << "Start " << timer.elapsed();
+#endif
+ freVerbDic->deconjugate(word, infles);
+
+ resultPages->setUpdatesEnabled(false);
+ std::string prevUTF8Infinitive, prevTemplateName; /* Remember found word
+ to avoid conjugating again */
+
+ for (std::vector<InflectionDesc>::const_iterator it = infles.begin();
+ it != infles.end(); it++)
+ {
+ const InflectionDesc &d = *it;
+
+#ifndef QT_NO_DEBUG
+ qDebug() << ">> Infinitive " << d.infinitive.c_str();
+ qDebug() << " Template " << d.templateName.c_str();
+#endif
+ /* If this infinitive has been conjugated, we skip to the next infinitive */
+ if (d.infinitive == prevUTF8Infinitive && d.templateName == prevTemplateName) {
+ continue;
+ }
+ /* FIXME:
+ * In original source (Verbiste), this checking is done later,
+ * after getConjugation(). I place it here to avoid calling again
+ * multitimes getConjugation(), which is very slow.
+ * We need to test more to see which place is more correct.
+ */
+
+ VVVS conjug;
+#ifndef QT_NO_DEBUG
+ qDebug() << " START getConjugation " << timer.elapsed();
+#endif
+ getConjugation(freVerbDic, d.infinitive, d.templateName, conjug,
+ #ifndef QT_NO_DEBUG
+ timer,
+ #endif
+ includePronouns);
+
+#ifndef QT_NO_DEBUG
+ qDebug() << " getConjugation() returns: " << timer.elapsed();
+#endif
+
+ if (conjug.size() == 0 // if no tenses
+ || conjug[0].size() == 0 // if no infinitive tense
+ || conjug[0][0].size() == 0 // if no person in inf. tense
+ || conjug[0][0][0].empty()) // if infinitive string empty
+ {
+ continue;
+ }
+
+ std::string utf8Infinitive = conjug[0][0][0];
+#ifndef QT_NO_DEBUG
+ qDebug() << " Infinitive " << utf8Infinitive.c_str();
+ qDebug() << " Template " << d.templateName.c_str();
+#endif
+
+ /* Add result to GUI (not show yet) */
+ ResultPage *rsp = addResultPage(utf8Infinitive);
+
+ /* Get modes and tenses of the verb */
+ int i = 0;
+ for (VVVS::const_iterator t = conjug.begin();
+ t != conjug.end(); t++, i++) {
+ if (i == 1)
+ i = 4;
+ else if (i == 11)
+ i = 12;
+ assert(i >= 0 && i < 16);
+
+ int row = i / 4;
+ int col = i % 4;
+
+ std::string utf8TenseName = getTenseNameForTableCell(row, col, isItalian);
+ if (utf8TenseName.empty())
+ continue;
+
+ QVBoxLayout *cell = makeResultCell(*t, utf8TenseName, word, freVerbDic);
+ rsp->grid->addLayout(cell, row, col);
+ }
+
+ /* Show the result on GUI */
+ rsp->packContent();
+ prevUTF8Infinitive = utf8Infinitive;
+ prevTemplateName = d.templateName;
+ }
+
+ /* Enable the button again */
+ btnLookup->setEnabled(true);
+ btnLookup->setText("");
+ resultPages->setUpdatesEnabled(true);