Skip to content

Commit

Permalink
Don't attempt implicit English deinflection of search terms
Browse files Browse the repository at this point in the history
Details: #41 (comment)

Since 6eb4787, this would report "No
results" for many alphabetic terms in Exact and Forward searches. While
this aspect could have been fixed, the deinflection could also dig up
unrelated words and was slowing down searches with additional queries.

A Forward Search for the stem accomplishes everything this feature was
trying to do, minus the surprise. So let's just drop it.

This reverts commit f01a37c
  • Loading branch information
mvf committed Jul 4, 2021
1 parent 47c3cba commit 78af8cc
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 52 deletions.
34 changes: 0 additions & 34 deletions src/method.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,37 +65,3 @@ QString Query::toLogicString() const
{
return query;
}

QStringList stemWords(const QString &words)
{
struct {
const char* suffix;
const char* stem;
} dict[] = {
{"ies", "y"},
{"ied", "y"},
{"es", ""},
{"ting", "te"},
{"ing", ""},
{"ing", "e"},
{"ed", "e"},
{"ed", ""},
{"id", "y"},
{"ices", "ex"},
{"ves", "fe"},
{"s", ""},
};

QStringList list;
for (size_t i=0; i<sizeof(dict)/sizeof(dict[0]); i++) {
QString suffix(dict[i].suffix);
if (words.endsWith(suffix, Qt::CaseInsensitive)) {
QString stem(dict[i].stem);
QString t(words);
t.chop(suffix.length());
t.append(stem);
list << t;
}
}
return list;
}
4 changes: 0 additions & 4 deletions src/method.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,4 @@ struct Query {
QString toLogicString() const;
};

QStringList stemWords(const QString &);

#define IGNORE_SEEK_HEADING

#endif
15 changes: 1 addition & 14 deletions src/searchpage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,9 @@ SearchPage::SearchPage(QWidget *parent, const SearchMethod &method)

RET_SEARCH SearchPage::search(const Query& query)
{
QStringList queries;
queries << query.query;
switch (query.method.direction) {
case ExactWordSearch:
case ForwardSearch:
queries << stemWords(query.query);
break;
default:
break;
}
RET_SEARCH retStatus = NOT_HIT;
PageItems items(CONF->dictSheet);
int itemIndex = 0;
foreach (const QString &q, queries) {
retStatus = doSearch(Query(q, query.method), items, itemIndex);
}
const RET_SEARCH retStatus = doSearch(query, items, itemIndex);

bookTree->insertTopLevelItems(0, items.topItems());
bookTree->setCurrentItem(bookTree->topLevelItem(0));
Expand Down

0 comments on commit 78af8cc

Please sign in to comment.