diff options
author | John Fultz <jfultz@wolfram.com> | 2015-09-26 10:47:07 -0500 |
---|---|---|
committer | John Fultz <jfultz@wolfram.com> | 2015-09-26 10:47:07 -0500 |
commit | 1214533715a1acfbc35ebe29ff78afee2f850226 (patch) | |
tree | 8c4c9a5280cfbb48b48dff2ae1c567364ea97e89 /quackleio/dawgfactory.cpp | |
parent | ed46987403dd923d3ba14df6eb676e1e163d1d8d (diff) |
Work on DAWG generation.
V1 DAWGs now include an alphabet.
Begin creating DAWGs which extend other DAWGs.
In general, laying the groundwork for plain text import
to DAWG.
Diffstat (limited to 'quackleio/dawgfactory.cpp')
-rw-r--r-- | quackleio/dawgfactory.cpp | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/quackleio/dawgfactory.cpp b/quackleio/dawgfactory.cpp index 3a971a3..565778a 100644 --- a/quackleio/dawgfactory.cpp +++ b/quackleio/dawgfactory.cpp @@ -50,21 +50,24 @@ bool DawgFactory::pushWord(const UVString& word, bool inSmaller, int playability UVString leftover; Quackle::LetterString encodedWord = m_alphas->encode(word, &leftover); if (leftover.empty()) - { - if (m_root.pushWord(encodedWord, inSmaller, playability)) - { - ++m_encodableWords; - hashWord(encodedWord); - return true; - } - ++m_duplicateWords; - return false; - } + return pushWord(encodedWord, inSmaller, playability); ++m_unencodableWords; return false; } +bool DawgFactory::pushWord(const Quackle::LetterString& word, bool inSmaller, int playability) +{ + if (m_root.pushWord(word, inSmaller, playability)) + { + ++m_encodableWords; + hashWord(word); + return true; + } + ++m_duplicateWords; + return false; +} + void DawgFactory::hashWord(const Quackle::LetterString &word) { QCryptographicHash wordhash(QCryptographicHash::Md5); @@ -139,6 +142,14 @@ void DawgFactory::writeIndex(const UVString& filename) out.put(1); // DAWG format version 1 out.write(m_hash.charptr, sizeof(m_hash.charptr)); out.write((char*)bytes, 3); + out.put((char)m_alphas->length()); + for (Quackle::Letter i = m_alphas->firstLetter(); i <= m_alphas->lastLetter(); i++) + { + QString letterText = QuackleIO::Util::uvStringToQString(m_alphas->letterParameter(i).text()); + QByteArray utf8bytes = letterText.toUtf8(); + string utf8LetterText(utf8bytes.constData()); + out << utf8LetterText << ' '; + } for (unsigned int i = 0; i < m_nodelist.size(); i++) { //cout << m_nodelist[i]->c << " " << m_nodelist[i]->pointer << " " << m_nodelist[i]->t << " " << m_nodelist[i]->lastchild << endl; |