55 unsigned int whole_word)
57 m_PatLen(pattern.length()),
58 m_CaseSensitive(case_sensitive),
59 m_WholeWord(whole_word),
60 m_LastOccurrence(sm_AlphabetSize),
61 m_WordDelimiters(sm_AlphabetSize)
73 const string& word_delimeters,
75 bool invert_delimiters)
77 m_PatLen(pattern.length()),
78 m_CaseSensitive(case_sensitive),
80 m_LastOccurrence(sm_AlphabetSize),
81 m_WordDelimiters(sm_AlphabetSize)
88 bool invert_delimiters)
92 string word_d = word_delimeters;
100 string::size_type
n = word_d.find_first_of(ch);
111 string word_d = word_delimeters;
118 string::size_type
n = word_d.find_first_of(ch);
145 if ((ch >=
'A' && ch <=
'Z') ||
146 (ch >=
'0' && ch <=
'9') ||
165 for (
size_t i = 0;
i <
size; ++
i ) {
186 while (shift +
m_PatLen <= text_len) {
199 while (shift +
m_PatLen <= text_len) {
243 right = (pos == text_len) ||
248 return (left && right);
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
CBoyerMooreMatcher(const string &pattern, NStr::ECase case_sensitive=NStr::eNocase, unsigned int whole_word=eSubstrMatch)
Initialize a matcher with the pattern to be matched.
NStr::ECase m_CaseSensitive
bool IsWholeWord(const char *text, SIZE_TYPE pos, SIZE_TYPE text_len) const
Check if the pattern at position pos in the text lies on a whole word boundry.
void SetWordDelimiters(const string &word_delimeters, bool invert_delimiters=false)
Set word delimiting characters.
void InitCommonDelimiters()
Init delimiters most common for the English language, (whitespaces, punctuations, etc)
void AddDelimiters(const string &word_delimeters)
Add new word delimiters.
vector< size_t > m_LastOccurrence
vector< unsigned char > m_WordDelimiters
static const int sm_AlphabetSize
size_t Search(const string &text, size_t pos=0) const
Search for the pattern over text starting at position pos.
NCBI_NS_STD::string::size_type SIZE_TYPE
ECase
Which type of string comparison.
static string & ToUpper(string &str)
Convert string to upper case – string& version.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
unsigned int
A callback function used to compare two keys in a database.
static void text(MDB_val *v)
const struct ncbi::grid::netcache::search::fields::SIZE size