-
-
Notifications
You must be signed in to change notification settings - Fork 46.9k
add ons in string directory - Boyer_Moore_Search #933
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
Conversation
I think it's "Boyer" Moore Search. If I'm right, please let me change it. |
Yes, it's my bad. I will edit it. Thanks.
…On Tue, Jul 2, 2019 at 1:59 PM Erfan Alimohammadi ***@***.***> wrote:
I think it's "Boyer" Moore Search. If I'm right, please let me change it.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#933?email_source=notifications&email_token=AHKYK4ZQ5VRGSOGWN73HUTDP5MGWLA5CNFSM4H4RQRW2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZAPYCA#issuecomment-507575304>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHKYK46ADOPY2BJO33NUBDDP5MGWLANCNFSM4H4RQRWQ>
.
|
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 make the requested changes.
strings/Boyer_Moore_Search.py
Outdated
m=length of pattern string | ||
""" | ||
|
||
class BayerMooreSearch: |
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 change the dictation mistake in the class name.
strings/Boyer_Moore_Search.py
Outdated
return currentPos + i | ||
return -1 | ||
|
||
def badCharacterHeuristic(self): |
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 snake_case for all methods.
Like: bad_character_heuristic
strings/Boyer_Moore_Search.py
Outdated
def badCharacterHeuristic(self): | ||
positions = [] | ||
for i in range(self.textLen - self.patLen + 1): | ||
misMatchIndex = self.misMatchInText(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.
Use snake_case: mismatch_index
Try to use it in all variable names.
strings/Boyer_Moore_Search.py
Outdated
return -1 | ||
|
||
|
||
""" following functions tries to find the mis-matched character's index in text from last, |
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.
Place docstrings after the "def" line.
Explain the parameters and the return value separately.
Please Google "Python docstrings conventions".
https://www.datacamp.com/community/tutorials/docstrings-python#second-head
strings/Boyer_Moore_Search.py
Outdated
pattern = "ABC" | ||
bms = BayerMooreSearch(text, pattern) | ||
positions = bms.badCharacterHeuristic() | ||
if(len(positions) == 0): |
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.
Unnecessary parentheses
strings/Boyer_Moore_Search.py
Outdated
print("No match found") | ||
else: | ||
print("Pattern found in following positions: ") | ||
print(positions) |
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.
I ran your code and the algorithm seems to work fine.
3377842
to
62d0413
Compare
#697, I have added Boyer Moore search function(bad character heuristic). Please review and let me know if any changes are required. Thanks. ;)