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
Aho corasick #1395
Aho corasick #1395
Conversation
… into Aho-Corasick
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.
Some changes to be done then we are good to go...
Aho-Corasick/Aho-Corasick.cpp
Outdated
of a finite set of strings (the "dictionary") within an input text. | ||
It matches all strings simultaneously.*/ | ||
|
||
const int MAXSTATETATE = 6 * 50 + 10; |
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.
MAXSTATETATE
sounds confusing/misspelled. Can you use something else in this place?
Aho-Corasick/Aho-Corasick.cpp
Outdated
memset(out, 0, sizeof out); //intializing out with 0s | ||
memset(fail, -1, sizeof fail); //intializing fail with -1s | ||
memset(g, -1, sizeof g); //intializing g with -1s | ||
int states = 1; // Initially, we just have the 0 state |
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.
Please use unified indentation for comments throughout the code.
Aho-Corasick/Aho-Corasick.cpp
Outdated
int currentState = 0; | ||
for (int j = 0; j < keyword.size(); j++) | ||
{ | ||
int c = keyword[j] - lowestChar; |
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.
Fix indentation.
Aho-Corasick/Aho-Corasick.cpp
Outdated
{ | ||
int c = keyword[j] - lowestChar; | ||
if (g[currentState][c] == -1) | ||
{ // Allocate a new node |
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.
Put comment in newline.
Aho-Corasick/Aho-Corasick.cpp
Outdated
vector<string> keywords; | ||
cout<<"Enter the number of keywords you want to enter"; | ||
int n; | ||
for(int i = 0; i < n; i++) |
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.
Add space after for
.
Aho-Corasick/Aho-Corasick.cpp
Outdated
{ | ||
string temp; | ||
cin >> temp; | ||
keywords.push_back(temp); |
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.
Fix indentation in above 3 lines.
Aho-Corasick/Aho-Corasick.cpp
Outdated
} | ||
cout << "Enter text"; | ||
string text; | ||
cin >> text; |
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.
No need to add space input (>>
) and output (<<
) operators in cin and cout statements.
Aho-Corasick/Aho-Corasick.cpp
Outdated
if (out[currentState] == 0) | ||
{ | ||
continue; // Nothing new, moving on to the next character. | ||
} |
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.
Fix indentation in above 3 lines.
Aho-Corasick/Aho-Corasick.cpp
Outdated
for (int j = 0; j < keywords.size(); j++) | ||
{ | ||
if (out[currentState] & (1 << j)) | ||
{ // Matched keywords[j] |
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.
Put comment in newline.
@marwahmanbir made the changes. |
Fixes #624
Checklist:
Changes proposed in this pull request:
Languages Used:
Files Added: