diff options
author | John Fultz <jfultz@wolfram.com> | 2015-10-14 01:29:30 -0500 |
---|---|---|
committer | John Fultz <jfultz@wolfram.com> | 2015-10-14 01:29:30 -0500 |
commit | fd6daafffbcce3bfc385d7508a1ca50174840912 (patch) | |
tree | 5fab061694d6856797e791a63b55c40e489a7e63 | |
parent | ef4273ba47a2da9cea0aed59235e2d0a86bb8d7e (diff) |
Convert dictionaries, add csw15.
* All dictionaries are now in v1 DAWG format.
* Three corrupt dictionaries were removed.
* Implement a way to tag dictionaries for copyright purposes.
* CSW15 is now a thing.
-rw-r--r-- | data/lexica/copyrights.txt | 2 | ||||
-rw-r--r-- | data/lexica/csw12.dawg | bin | 1600543 -> 1600616 bytes | |||
-rw-r--r-- | data/lexica/csw15.dawg | bin | 0 -> 1459769 bytes | |||
-rw-r--r-- | data/lexica/cswapr07.dawg | bin | 2641009 -> 2641082 bytes | |||
-rw-r--r-- | data/lexica/greek.dawg | bin | 1248807 -> 1248900 bytes | |||
-rw-r--r-- | data/lexica/korean.dawg | bin | 1014944 -> 1015145 bytes | |||
-rw-r--r-- | data/lexica/norwegian.dawg | bin | 1701427 -> 1701518 bytes | |||
-rw-r--r-- | data/lexica/ods5.dawg | bin | 899171 -> 899244 bytes | |||
-rw-r--r-- | data/lexica/osps.dawg | bin | 2570477 -> 2570571 bytes | |||
-rw-r--r-- | data/lexica/russian.dawg | bin | 240528 -> 0 bytes | |||
-rw-r--r-- | data/lexica/sowpods.dawg | bin | 1473486 -> 1473559 bytes | |||
-rw-r--r-- | data/lexica/tuvan.dawg | bin | 15492 -> 0 bytes | |||
-rw-r--r-- | data/lexica/twl06.dawg | bin | 1816584 -> 1816657 bytes | |||
-rw-r--r-- | data/lexica/twl06_wild.dawg | bin | 6215056 -> 0 bytes | |||
-rw-r--r-- | data/lexica/twl98.dawg | bin | 938070 -> 938143 bytes | |||
-rw-r--r-- | lexiconparameters.cpp | 27 | ||||
-rw-r--r-- | lexiconparameters.h | 4 | ||||
-rw-r--r-- | quacker/lexicondialog.cpp | 3 | ||||
-rw-r--r-- | quacker/quacker.cpp | 32 | ||||
-rw-r--r-- | quacker/settings.cpp | 12 | ||||
-rw-r--r-- | quacker/settings.h | 2 | ||||
-rw-r--r-- | quackle.sublime-project | 4 |
22 files changed, 63 insertions, 23 deletions
diff --git a/data/lexica/copyrights.txt b/data/lexica/copyrights.txt new file mode 100644 index 0000000..1e3e553 --- /dev/null +++ b/data/lexica/copyrights.txt @@ -0,0 +1,2 @@ +eea8dfe5:Collins Scrabble™ Words 2012, ©HarperCollins Publishers Ltd 2015 +48dea2c8:Collins Scrabble™ Words 2015, ©HarperCollins Publishers Ltd 2015 diff --git a/data/lexica/csw12.dawg b/data/lexica/csw12.dawg Binary files differindex f98ef8b..822bd95 100644 --- a/data/lexica/csw12.dawg +++ b/data/lexica/csw12.dawg diff --git a/data/lexica/csw15.dawg b/data/lexica/csw15.dawg Binary files differnew file mode 100644 index 0000000..da4defa --- /dev/null +++ b/data/lexica/csw15.dawg diff --git a/data/lexica/cswapr07.dawg b/data/lexica/cswapr07.dawg Binary files differindex a2863ac..6e6dca7 100644 --- a/data/lexica/cswapr07.dawg +++ b/data/lexica/cswapr07.dawg diff --git a/data/lexica/greek.dawg b/data/lexica/greek.dawg Binary files differindex 90835e5..b8666ec 100644 --- a/data/lexica/greek.dawg +++ b/data/lexica/greek.dawg diff --git a/data/lexica/korean.dawg b/data/lexica/korean.dawg Binary files differindex 6aa5d3e..c55769e 100644 --- a/data/lexica/korean.dawg +++ b/data/lexica/korean.dawg diff --git a/data/lexica/norwegian.dawg b/data/lexica/norwegian.dawg Binary files differindex 0acdb33..2db2269 100644 --- a/data/lexica/norwegian.dawg +++ b/data/lexica/norwegian.dawg diff --git a/data/lexica/ods5.dawg b/data/lexica/ods5.dawg Binary files differindex eabc68a..8d440d9 100644 --- a/data/lexica/ods5.dawg +++ b/data/lexica/ods5.dawg diff --git a/data/lexica/osps.dawg b/data/lexica/osps.dawg Binary files differindex 6c02ecd..6d81d3d 100644 --- a/data/lexica/osps.dawg +++ b/data/lexica/osps.dawg diff --git a/data/lexica/russian.dawg b/data/lexica/russian.dawg Binary files differdeleted file mode 100644 index 3b01c8e..0000000 --- a/data/lexica/russian.dawg +++ /dev/null diff --git a/data/lexica/sowpods.dawg b/data/lexica/sowpods.dawg Binary files differindex b5d89df..e052222 100644 --- a/data/lexica/sowpods.dawg +++ b/data/lexica/sowpods.dawg diff --git a/data/lexica/tuvan.dawg b/data/lexica/tuvan.dawg Binary files differdeleted file mode 100644 index f5f31b3..0000000 --- a/data/lexica/tuvan.dawg +++ /dev/null diff --git a/data/lexica/twl06.dawg b/data/lexica/twl06.dawg Binary files differindex 9388487..e0afed7 100644 --- a/data/lexica/twl06.dawg +++ b/data/lexica/twl06.dawg diff --git a/data/lexica/twl06_wild.dawg b/data/lexica/twl06_wild.dawg Binary files differdeleted file mode 100644 index 34e78a0..0000000 --- a/data/lexica/twl06_wild.dawg +++ /dev/null diff --git a/data/lexica/twl98.dawg b/data/lexica/twl98.dawg Binary files differindex a835b7c..e6f451e 100644 --- a/data/lexica/twl98.dawg +++ b/data/lexica/twl98.dawg diff --git a/lexiconparameters.cpp b/lexiconparameters.cpp index 74de78f..f04a941 100644 --- a/lexiconparameters.cpp +++ b/lexiconparameters.cpp @@ -132,7 +132,7 @@ class Quackle::V1LexiconInterpreter : public LexiconInterpreter }; LexiconParameters::LexiconParameters() - : m_dawg(NULL), m_gaddag(NULL), m_interpreter(NULL), m_wordCount(0) + : m_dawg(NULL), m_gaddag(NULL), m_interpreter(NULL) { memset(m_hash, 0, sizeof(m_hash)); } @@ -228,22 +228,37 @@ bool LexiconParameters::hasUserDictionaryFile(const string &lexicon) return QUACKLE_DATAMANAGER->hasUserDataFile("lexica", lexicon); } -UVString LexiconParameters::hashString(bool shortened) const +string LexiconParameters::hashString(bool shortened) const { - const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; + const char hex[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; string hashStr; for (size_t i = 0; i < sizeof(m_hash); i++) { hashStr.push_back(hex[(m_hash[i] & 0xF0) >> 4]); hashStr.push_back(hex[m_hash[i] & 0x0F]); - if (shortened && i == 5) + if (shortened && i == 3) break; - if (i % 2 == 1) - hashStr.push_back('-'); } return hashStr; } +string LexiconParameters::copyrightString() const +{ + string copyrightsFilename = QUACKLE_DATAMANAGER->makeDataFilename("lexica", "copyrights.txt", false); + fstream copyrightsFile(copyrightsFilename, ios_base::in); + while (copyrightsFile.good() && !copyrightsFile.eof()) + { + string line; + getline(copyrightsFile, line); + if (line.size() < 9 || line.find_first_of(':') != 8) + continue; + if (hashString(true).compare(line.substr(0,8)) != 0) + continue; + return line.substr(9, line.size()); + } + return string(); +} + LexiconInterpreter* LexiconParameters::createInterpreter(char version) const { switch(version) diff --git a/lexiconparameters.h b/lexiconparameters.h index f29a589..d19f695 100644 --- a/lexiconparameters.h +++ b/lexiconparameters.h @@ -80,7 +80,8 @@ public: } const GaddagNode *gaddagRoot() const { return (GaddagNode *) &m_gaddag[0]; }; - UVString hashString(bool shortened) const; + string hashString(bool shortened) const; + string copyrightString() const; protected: unsigned char *m_dawg; @@ -88,7 +89,6 @@ protected: string m_lexiconName; LexiconInterpreter *m_interpreter; char m_hash[16]; - int m_wordCount; vector<string> m_utf8Alphabet; LexiconInterpreter* createInterpreter(char version) const; diff --git a/quacker/lexicondialog.cpp b/quacker/lexicondialog.cpp index 6630e1f..91eb676 100644 --- a/quacker/lexicondialog.cpp +++ b/quacker/lexicondialog.cpp @@ -117,6 +117,7 @@ LexiconDialog::LexiconDialog(QWidget *parent, const QString &originalName) : QDi setWindowTitle(tr("Configure Lexicon - Quackle")); Settings::populateComboFromFilenames(m_alphabetCombo, "alphabets", ".quackle_alphabet", ""); + m_alphabetCombo->setCurrentIndex(m_alphabetCombo->findText(QuackleIO::Util::stdStringToQString(QUACKLE_ALPHABET_PARAMETERS->alphabetName()))); alphabetChanged(m_alphabetCombo->currentText()); m_lexiconName->setValidator(m_fileNameValidator); @@ -300,6 +301,6 @@ void LexiconDialog::updateLexiconInformation(bool firstTime) m_lexiconInformation->setText(text); - m_saveChanges->setEnabled(hash != m_originalHash && !m_lexiconName->text().isEmpty()); + m_saveChanges->setEnabled(true/*hash != m_originalHash && !m_lexiconName->text().isEmpty()*/); m_clearAllWords->setEnabled(hash != m_originalHash); } diff --git a/quacker/quacker.cpp b/quacker/quacker.cpp index a1f7064..2f407fa 100644 --- a/quacker/quacker.cpp +++ b/quacker/quacker.cpp @@ -155,13 +155,10 @@ void TopLevel::finishInitialization() void TopLevel::introduceToUser() { CustomQSettings settings; - QString lexiconName = settings.value("quackle/settings/lexicon-name", QString("twl06")).toString(); - if (lexiconName == "csw12") { - statusMessage(tr("The WESPA wordlist (CSW12) is copyright Harper Collins 2011.")); - } else { - statusMessage(tr("Enjoy your quackling. Choose \"New game...\" from the Game menu to begin.")); - } - + QString statusText = QString::fromUtf8(QUACKLE_LEXICON_PARAMETERS->copyrightString().c_str()); + if (statusText.isEmpty()) + statusText = tr("Enjoy your quackling. Choose \"New game...\" from the Game menu to begin."); + statusMessage(statusText); parseCommandLineOptions(); if (!CustomQSettings().contains("quackle/hasBeenRun")) @@ -2120,7 +2117,7 @@ void TopLevel::firstTimeRun() void TopLevel::about() { - QMessageBox::about(this, tr("About Quackle 1.0"), dialogText(tr( + QString aboutText = tr( "<p><b>Quackle</b> 1.0 is a crossword game playing, analysis, and study tool. Visit the Quackle homepage at <tt><a href=\"http://quackle.org\">http://quackle.org</a></tt> for more information.</p>" "<p>Quackle was written by Jason Katz-Brown, John O'Laughlin, John Fultz, Matt Liberty, and Anand Buddhdev. We thank the anonymous donor who made this software free.</p>" "<p>Copyright 2005-2015 by</p>" @@ -2130,7 +2127,24 @@ void TopLevel::about() "</ul>" "<p>Quackle is free, open-source software licensed under the terms of the GNU General Public License Version 3. See</p>" "<p><tt><a href=\"http://quackle.org/LICENSE\">http://quackle.org/LICENSE</a></tt></p>" -))); +"<p>Dictionary copyrights</p><ul>" +); + + FILE* file = fopen(QUACKLE_DATAMANAGER->makeDataFilename("lexica", "copyrights.txt", false).c_str(), "r"); + if (file) + { + QTextStream strm(file); + while (!strm.atEnd()) + { + QString line = strm.readLine(); + int pos = line.indexOf(':'); + if (pos != -1 && pos + 1 < line.size()) + aboutText += "<li>" + line.mid(pos + 1) + "</li>"; + } + fclose(file); + aboutText += "</ul>"; + } + QMessageBox::about(this, tr("About Quackle 1.0"), dialogText(aboutText)); } void TopLevel::hints() diff --git a/quacker/settings.cpp b/quacker/settings.cpp index 6435605..e22a29e 100644 --- a/quacker/settings.cpp +++ b/quacker/settings.cpp @@ -148,6 +148,8 @@ void Settings::createGUI() m_editBoard->setMaximumWidth(60); connect(m_editBoard, SIGNAL(clicked()), this, SLOT(editBoard())); + m_copyrightLabel = new QLabel(); + layout->addWidget(lexiconNameLabel, 0, 0, Qt::AlignRight); layout->addWidget(m_lexiconNameCombo, 0, 1); layout->addWidget(m_editLexicon, 0, 2); @@ -160,25 +162,28 @@ void Settings::createGUI() layout->addWidget(boardNameLabel, 3, 0, Qt::AlignRight); layout->addWidget(m_boardNameCombo, 3, 1); layout->addWidget(m_editBoard, 3, 2); + layout->addWidget(m_copyrightLabel, 4, 0, 1, -1, Qt::AlignTop); layout->setColumnMinimumWidth(3, 0); layout->setColumnStretch(3, 1); layout->setRowMinimumHeight(4, 0); layout->setRowStretch(4, 1); + load(); } void Settings::load() { - m_lexiconNameCombo->setCurrentIndex(m_lexiconNameCombo->findText(QuackleIO::Util::stdStringToQString(QUACKLE_LEXICON_PARAMETERS->lexiconName()))); + m_lexiconNameCombo->setCurrentIndex(m_lexiconNameCombo->findText(QString::fromUtf8(QUACKLE_LEXICON_PARAMETERS->lexiconName().c_str()))); if (m_lexiconNameCombo->currentIndex() == -1) - m_lexiconNameCombo->setCurrentIndex(m_lexiconNameCombo->findText(QuackleIO::Util::stdStringToQString(QUACKLE_LEXICON_PARAMETERS->lexiconName()) + "*")); + m_lexiconNameCombo->setCurrentIndex(m_lexiconNameCombo->findText(QString::fromUtf8(QUACKLE_LEXICON_PARAMETERS->lexiconName().c_str()) + "*")); m_lastGoodLexiconValue = m_lexiconNameCombo->currentIndex(); - m_alphabetNameCombo->setCurrentIndex(m_alphabetNameCombo->findText(QuackleIO::Util::stdStringToQString(QUACKLE_ALPHABET_PARAMETERS->alphabetName()))); + m_alphabetNameCombo->setCurrentIndex(m_alphabetNameCombo->findText(QString::fromUtf8(QUACKLE_ALPHABET_PARAMETERS->alphabetName().c_str()))); m_themeNameCombo->setCurrentIndex(m_themeNameCombo->findText(m_themeName)); m_boardNameCombo->setCurrentIndex(m_boardNameCombo->findText(QuackleIO::Util::uvStringToQString(QUACKLE_BOARD_PARAMETERS->name()))); m_lastGoodBoardValue = m_boardNameCombo->currentIndex(); + m_copyrightLabel->setText(QString::fromUtf8(QUACKLE_LEXICON_PARAMETERS->copyrightString().c_str())); } void Settings::preInitialize() @@ -279,6 +284,7 @@ void Settings::setQuackleToUseLexiconName(const QString &lexiconName) // } QUACKLE_STRATEGY_PARAMETERS->initialize(lexiconNameStr); + m_copyrightLabel->setText(QString::fromUtf8(QUACKLE_LEXICON_PARAMETERS->copyrightString().c_str())); } } diff --git a/quacker/settings.h b/quacker/settings.h index babea3c..ef3449e 100644 --- a/quacker/settings.h +++ b/quacker/settings.h @@ -29,6 +29,7 @@ class QComboBox; class QCheckBox; class QPushButton; +class QLabel; using namespace std; @@ -88,6 +89,7 @@ protected: QPushButton *m_editAlphabet; QPushButton *m_editTheme; QPushButton *m_editBoard; + QLabel *m_copyrightLabel; QString m_appDataDir; QString m_userDataDir; QString m_themeName; diff --git a/quackle.sublime-project b/quackle.sublime-project index 2ca8db5..c7f47cd 100644 --- a/quackle.sublime-project +++ b/quackle.sublime-project @@ -6,8 +6,8 @@ "file_exclude_patterns" : ["*.tgz", "*.sublime-workspace", ".tags*", "dawginput.raw", "playabilities.raw", "smaller.raw", ".gitattributes", "*.Debug", "*.Release", "*.pfx", "*.cer", - "makegaddag", "makeminidawg", "gaddagize", "Makefile"], - "folder_exclude_patterns" : ["obj", "moc", "build", "*.xcodeproj", "lib", "lexica", + "makegaddag", "makeminidawg", "gaddagize", "Makefile", "*.dawg", "*.gaddag"], + "folder_exclude_patterns" : ["obj", "moc", "build", "*.xcodeproj", "lib", "strategy", "debug", "release", "makeswelexicon", "lisp", "DerivedData"] } ] |