-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add AhoCorasick #545
Add AhoCorasick #545
Conversation
Presently, there are a few things that I'm not sure about when writing the doc. Specifically:
Any insight would be much appreciated! |
//! This function puts an AhoCorasick object back into the same state as if | ||
//! it had been newly default constructed. | ||
//! | ||
//! \parameters (None) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think we agreed to not document no parameters or return value in this way.
AhoCorasick& init(); | ||
|
||
size_t number_of_nodes() const noexcept { | ||
//! Returns the number of nodes in the forest. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
forest
-> trie
?
//! \brief Add a word to the trie. | ||
//! | ||
//! Calling this function immediately adds the given word to the trie, and | ||
//! sets the final node to terminal (if it is not already the case). After |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
//! sets the final node to terminal (if it is not already the case). After | |
//! makes the final node on the path labelled by this word terminal (if it wasn't already). After |
tests/test-aho-corasick.cpp
Outdated
for (auto const& w : words) { | ||
aho_corasick::add_word(ac, w); | ||
} | ||
std::cout << "\n" << dot(ac).to_string() << "\n"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better to check that REQUIRE(dot(ac).to_string() == "")
instead. Or if you really want to insert it in a stream then make a stringstream
so that the output is swallowed by that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, few minor quibbles, but happy to merge this more or less as is
Correction will be happy to merge when the CI passes :) |
Thanks for the review @james-d-mitchell. Will finish up the docs, do the Python bindings then un-draft-ify the PR. |
Any where you can more or less straightforwardly determine what the complexity is.
I find that often in the brief docs it's too long to write "This function calculates..." or equivalent, so often just remove it. In the detailed description, it's probably better to write something like "This function ...".
By describing when it throws, or maybe more accurately by describing when libsemigroups throws (through
IIRC
I've written that in lots of places, because the detail description often say what is returned already, and it's a little less repetitive. In the python bindings these returns statements are useless, so maybe it's better to just briefly repeat what is returned Hope this helps! |
ff19397
to
a176b23
Compare
da14334
to
236ccda
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
This PR includes the AhoCorasick class in a state ready for V3. In particular:
no_checks
functionsiwyu