summaryrefslogtreecommitdiff
path: root/quacker/settings.cpp
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2015-11-06 08:50:41 -0600
committerJohn Fultz <jfultz@wolfram.com>2015-11-06 08:50:41 -0600
commit656b3c684d8dbf25e39517f5bf1bf9d53d9cb19d (patch)
treeee8cdc047e8a843fb63216622f2665c2d6ced330 /quacker/settings.cpp
parent7d6f193908a0b277a5b44f0d22651dccec033b70 (diff)
Set up defaults strategies.
So, basically, the dictionary is queried to see if it's "English-like". Which is to say that it uses the same alphabet. If so, then it will fall back to use twl06 strategies, minus the superleaves (the so-called "default_english"). Otherwise, it uses "default" strategies, which right now is simply a worths file that sets the blank to be 30. It's not great. But better than before.
Diffstat (limited to 'quacker/settings.cpp')
-rw-r--r--quacker/settings.cpp21
1 files changed, 20 insertions, 1 deletions
diff --git a/quacker/settings.cpp b/quacker/settings.cpp
index 89a19d8..cd6de27 100644
--- a/quacker/settings.cpp
+++ b/quacker/settings.cpp
@@ -205,7 +205,6 @@ void Settings::initialize()
{
CustomQSettings settings;
- QUACKLE_DATAMANAGER->setBackupLexicon("twl06");
QUACKLE_DATAMANAGER->setAppDataDirectory(m_appDataDir.toStdString());
QUACKLE_DATAMANAGER->setUserDataDirectory(m_userDataDir.toStdString());
@@ -302,6 +301,8 @@ void Settings::pushIndex(GaddagFactory &factory, Quackle::LetterString &word, in
void Settings::setQuackleToUseLexiconName(const QString &lexiconName)
{
+ QUACKLE_DATAMANAGER->setBackupLexicon("default");
+
string lexiconNameStr = lexiconName.toStdString();
if (QUACKLE_LEXICON_PARAMETERS->lexiconName() != lexiconNameStr)
{
@@ -331,6 +332,24 @@ void Settings::setQuackleToUseLexiconName(const QString &lexiconName)
else
QUACKLE_LEXICON_PARAMETERS->loadGaddag(gaddagFile);
+ // Dirty test to see if we're working with an English-like dictionary, and if so, beef up
+ // strategy files with twl06 ones (until I can start generating better). It's an imperfect
+ // test...it captures the ODS dictionary, for example, which seems pretty wrong. But I
+ // don't want to hard-code lexicon names here, so this is about as good as I can do.
+ const vector<string> & alphabet = QUACKLE_LEXICON_PARAMETERS->utf8Alphabet();
+ if (alphabet.size() == 26)
+ {
+ vector<string>::const_iterator it;
+ for (it = alphabet.begin(); it != alphabet.end(); it++)
+ {
+ if (it->size() != 1)
+ break;
+ if (it->c_str()[0] < 'A' || it->c_str()[0] > 'Z')
+ break;
+ }
+ if (it == alphabet.end())
+ QUACKLE_DATAMANAGER->setBackupLexicon("default_english");
+ }
QUACKLE_STRATEGY_PARAMETERS->initialize(lexiconNameStr);
m_copyrightLabel->setText(QString::fromUtf8(QUACKLE_LEXICON_PARAMETERS->copyrightString().c_str()));
setGaddagLabel();