MCPcopy Create free account
hub / github.com/albertlauncher/albert / preprocessQuery

Function preprocessQuery

src/util/querypreprocessing.cpp:9–50  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7using namespace albert;
8
9QStringList preprocessQuery(QString s, const MatchConfig &config)
10{
11 if (config.ignore_diacritics)
12 {
13 static const QRegularExpression re(
14 "(["
15 R"(\x{0300}-\x{036f})" // diacritical marks
16 "\u00AD" // Soft hyphen
17 "])");
18 s = s.normalized(QString::NormalizationForm_D).remove(re);
19 }
20 else
21 {
22 // Remove soft hyphens
23 s.remove(QChar(0x00AD));
24 }
25
26 if (config.ignore_case)
27 s = s.toLower();
28
29 QTextBoundaryFinder finder(QTextBoundaryFinder::Word, s);
30 QStringList tokens;
31 qsizetype begin = 0;
32 for (qsizetype end = finder.toNextBoundary();
33 end != -1;
34 end = finder.toNextBoundary())
35 {
36 if (begin != end)
37 {
38 // Only add non-space tokens
39 // Assumes that the tokes that either are all spaces or non-spaces
40 if(!s[begin].isSpace())
41 tokens << s.mid(begin, end - begin);
42 begin = end;
43 }
44 }
45
46 if (config.ignore_word_order)
47 tokens.sort();
48
49 return tokens;
50}
51
52QStringList preprocessLegacy(QString s)
53{

Callers 5

match_configMethod · 0.85
matchMethod · 0.85
MatcherMethod · 0.85
setItemsMethod · 0.85
searchMethod · 0.85

Calls

no outgoing calls

Tested by 1

match_configMethod · 0.68