Skip to content

add ons in string directory - Boyer_Moore_Search - #933

Merged
Erfaniaa merged 1 commit into
TheAlgorithms:masterfrom
Dharni0607:issue#697
Jul 2, 2019
Merged

add ons in string directory - Boyer_Moore_Search#933
Erfaniaa merged 1 commit into
TheAlgorithms:masterfrom
Dharni0607:issue#697

Conversation

@Dharni0607

@Dharni0607Dharni0607 commented Jul 1, 2019

Copy link
Copy Markdown
Contributor

#697, I have added Boyer Moore search function(bad character heuristic). Please review and let me know if any changes are required. Thanks. ;)

@Erfaniaa

Copy link
Copy Markdown
Member

I think it's "Boyer" Moore Search. If I'm right, please let me change it.

@Dharni0607

Dharni0607 commented Jul 2, 2019 via email

Copy link
Copy Markdown
ContributorAuthor

@Dharni0607Dharni0607 changed the title add ons in string directory - Bayer_Moore_Searchadd ons in string directory - Boyer_Moore_SearchJul 2, 2019
@Erfaniaa
Erfaniaa removed the request for review from poyeaJuly 2, 2019 08:33

@ErfaniaaErfaniaa left a comment

Copy link
Copy Markdown
Member

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.

Comment threadstrings/Boyer_Moore_Search.py Outdated
m=length of pattern string
"""

class BayerMooreSearch:

Copy link
Copy Markdown
Member

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.

Comment threadstrings/Boyer_Moore_Search.py Outdated
return currentPos + i
return -1

def badCharacterHeuristic(self):

Copy link
Copy Markdown
Member

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

Comment threadstrings/Boyer_Moore_Search.py Outdated
def badCharacterHeuristic(self):
positions = []
for i in range(self.textLen - self.patLen + 1):
misMatchIndex = self.misMatchInText(i)

Copy link
Copy Markdown
Member

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.

Comment threadstrings/Boyer_Moore_Search.py Outdated
return -1


""" following functions tries to find the mis-matched character's index in text from last,

Copy link
Copy Markdown
Member

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

Comment threadstrings/Boyer_Moore_Search.py Outdated
pattern = "ABC"
bms = BayerMooreSearch(text, pattern)
positions = bms.badCharacterHeuristic()
if(len(positions) == 0):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary parentheses

Comment threadstrings/Boyer_Moore_Search.py Outdated
print("No match found")
else:
print("Pattern found in following positions: ")
print(positions)

Copy link
Copy Markdown
Member

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.

@Dharni0607
Dharni0607force-pushed the issue#697 branch 4 times, most recently from 3377842 to 62d0413CompareJuly 2, 2019 11:59
@Erfaniaa
Erfaniaa merged commit 27a8184 into TheAlgorithms:masterJul 2, 2019
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@Dharni0607@Erfaniaa@poyea