aho_corasick icon indicating copy to clipboard operation
aho_corasick copied to clipboard

Adding empty string matches too

Open johny7 opened this issue 7 years ago • 0 comments

It is just desired to have empty string matches too, if necessary. Another bonus would be to return index directly from insert() method, to simplify index based matching with associated data later on. Also, added const ref to the argument of insert

This changes are proposed:

at the start of the insert method:

int insert(const string_type& keyword) { // commented to allow empty string matches too // if (keyword.empty()) // return;

..

in the end of the insert method:

// bugfix, proposed here https://github.com/cjgdev/aho_corasick/issues/7 d_constructed_failure_states = false; return d_num_keywords-1;

--

At emit_collection parse_text(string_type text):

emit_collection collected_emits; // added to collect empty string matches too store_emits( pos, cur_state, collected_emits ); for( auto c : text ) {

johny7 avatar Apr 20 '17 03:04 johny7