summaryrefslogtreecommitdiff
path: root/lexiconparameters.cpp
diff options
context:
space:
mode:
authorJohn Fultz <jfultz@wolfram.com>2015-10-14 01:29:30 -0500
committerJohn Fultz <jfultz@wolfram.com>2015-10-14 01:29:30 -0500
commitfd6daafffbcce3bfc385d7508a1ca50174840912 (patch)
tree5fab061694d6856797e791a63b55c40e489a7e63 /lexiconparameters.cpp
parentef4273ba47a2da9cea0aed59235e2d0a86bb8d7e (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.
Diffstat (limited to 'lexiconparameters.cpp')
-rw-r--r--lexiconparameters.cpp27
1 files changed, 21 insertions, 6 deletions
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)