aho_corasick
aho_corasick copied to clipboard
Adding empty string matches too
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 ) {