mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2024-11-17 07:48:27 +01:00
Little hack to have the 7+1 search in alphabetical order (or more precisely, in the order of the letters as defined at dictionary creation)
This commit is contained in:
parent
bb13f634b3
commit
43d42a0388
4 changed files with 21 additions and 16 deletions
|
@ -232,13 +232,18 @@ public:
|
|||
|
||||
/**
|
||||
* Search for all feasible word with "rack" plus one letter
|
||||
* XXX: the key in the map is the internal code, because it allows an easy
|
||||
* iteration in the map in the order of the dictionary letters.
|
||||
* Maybe a more powerful structure should be provided, to hide the internal
|
||||
* chars to the caller.
|
||||
*
|
||||
* @param iRack: letters
|
||||
* @param oWordlist: results (grouped by added character)
|
||||
* @param oWordlist: results (grouped by code of the added character)
|
||||
* @param joker: true if the search must be performed when a joker is in the rack
|
||||
* @param iMaxResults: maximum number of returned results (0 means no limit)
|
||||
*/
|
||||
void search7pl1(const wstring &iRack,
|
||||
map<wstring, vector<wdstring> > &oWordList,
|
||||
map<unsigned int, vector<wdstring> > &oWordList,
|
||||
bool joker) const;
|
||||
|
||||
/**
|
||||
|
|
|
@ -76,9 +76,9 @@ bool Dictionary::searchWord(const wstring &iWord) const
|
|||
|
||||
struct params_7plus1_t
|
||||
{
|
||||
wchar_t added_code;
|
||||
unsigned int added_code;
|
||||
wdstring added_display;
|
||||
map<wdstring, vector<wdstring> > *results;
|
||||
map<unsigned int, vector<wdstring> > *results;
|
||||
int search_len;
|
||||
wchar_t search_wordtst[DIC_WORD_MAX];
|
||||
char search_letters[63];
|
||||
|
@ -103,7 +103,7 @@ void Dictionary::searchWordByLen(struct params_7plus1_t ¶ms,
|
|||
if (edgeptr->term)
|
||||
{
|
||||
// Add the solution
|
||||
vector<wdstring> &sols = (*params.results)[params.added_display];
|
||||
vector<wdstring> &sols = (*params.results)[params.added_code];
|
||||
if (sols.empty() || sols.back() != params.search_wordtst)
|
||||
sols.push_back(convertToDisplay(params.search_wordtst));
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ void Dictionary::searchWordByLen(struct params_7plus1_t ¶ms,
|
|||
if (edgeptr->term)
|
||||
{
|
||||
// Add the solution
|
||||
vector<wdstring> &sols = (*params.results)[params.added_display];
|
||||
vector<wdstring> &sols = (*params.results)[params.added_code];
|
||||
if (sols.empty() || sols.back() != params.search_wordtst)
|
||||
sols.push_back(convertToDisplay(params.search_wordtst));
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ void Dictionary::searchWordByLen(struct params_7plus1_t ¶ms,
|
|||
|
||||
|
||||
void Dictionary::search7pl1(const wstring &iRack,
|
||||
map<wdstring, vector<wdstring> > &oWordList,
|
||||
map<unsigned int, vector<wdstring> > &oWordList,
|
||||
bool joker) const
|
||||
{
|
||||
if (iRack == L"" || iRack.size() > DIC_WORD_MAX)
|
||||
|
@ -407,7 +407,6 @@ bool Dictionary::searchRegExp(const wstring &iRegexp,
|
|||
unsigned int iMaxLength,
|
||||
unsigned int iMaxResults) const
|
||||
{
|
||||
// XXX: throw an exception?
|
||||
if (iRegexp == L"")
|
||||
return true;
|
||||
|
||||
|
|
|
@ -200,18 +200,18 @@ void DicToolsWidget::refreshPlus1()
|
|||
|
||||
if (input != L"")
|
||||
{
|
||||
map<wstring, vector<wstring> > wordList;
|
||||
map<unsigned int, vector<wstring> > wordList;
|
||||
m_dic->search7pl1(input, wordList, true);
|
||||
|
||||
int rowNum = 0;
|
||||
map<wstring, vector<wstring> >::const_iterator it;
|
||||
map<unsigned int, vector<wstring> >::const_iterator it;
|
||||
for (it = wordList.begin(); it != wordList.end(); it++)
|
||||
{
|
||||
// Create the header line
|
||||
model->insertRow(rowNum);
|
||||
const QModelIndex &index = model->index(rowNum, 0);
|
||||
if (it->first != L"")
|
||||
model->setData(index, qfw(it->first));
|
||||
if (it->first != 0)
|
||||
model->setData(index, qfw(m_dic->getHeader().getDisplayStr(it->first)));
|
||||
else
|
||||
model->setData(index, _q("Anagrams"));
|
||||
treeView->setExpanded(index, true);
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#endif
|
||||
|
||||
#include "dic.h"
|
||||
#include "header.h"
|
||||
#include "dic_exception.h"
|
||||
#include "game_io.h"
|
||||
#include "game_factory.h"
|
||||
|
@ -601,13 +602,13 @@ void loopTraining(PublicGame &iGame)
|
|||
break;
|
||||
case L'p':
|
||||
{
|
||||
map<wdstring, vector<wdstring> > wordMap;
|
||||
map<unsigned int, vector<wdstring> > wordMap;
|
||||
iGame.getDic().search7pl1(word, wordMap, false);
|
||||
map<wdstring, vector<wdstring> >::const_iterator it;
|
||||
map<unsigned int, vector<wdstring> >::const_iterator it;
|
||||
for (it = wordMap.begin(); it != wordMap.end(); ++it)
|
||||
{
|
||||
if (it->first != L"")
|
||||
cout << "+" << convertToMb(it->first) << endl;
|
||||
if (it->first != 0)
|
||||
cout << "+" << convertToMb(iGame.getDic().getHeader().getDisplayStr(it->first)) << endl;
|
||||
BOOST_FOREACH(const wdstring &wstr, it->second)
|
||||
{
|
||||
cout << " " << convertToMb(wstr) << endl;
|
||||
|
|
Loading…
Reference in a new issue