Create codespell.yml (#1698)

* fixup! Format Python code with psf/black push

* Create codespell.yml

* fixup! Format Python code with psf/black push
This commit is contained in:
Christian Clauss
2020-01-18 13:24:33 +01:00
committed by GitHub
parent c01d178798
commit bfcb95b297
78 changed files with 206 additions and 188 deletions

View File

@@ -67,7 +67,7 @@ class Automaton:
>>> A.search_in("whatever, err ... , wherever")
{'what': [0], 'hat': [1], 'ver': [5, 25], 'er': [6, 10, 22, 26]}
"""
result = dict() # returns a dict with keywords and list of its occurences
result = dict() # returns a dict with keywords and list of its occurrences
current_state = 0
for i in range(len(string)):
while (

View File

@@ -27,7 +27,7 @@ class BoyerMooreSearch:
def match_in_pattern(self, char):
""" finds the index of char in pattern in reverse order
Paremeters :
Parameters :
char (chr): character to be searched
Returns :
@@ -43,12 +43,12 @@ class BoyerMooreSearch:
def mismatch_in_text(self, currentPos):
""" finds the index of mis-matched character in text when compared with pattern from last
Paremeters :
Parameters :
currentPos (int): current index position of text
Returns :
i (int): index of mismatched char from last in text
-1 (int): if there is no mis-match between pattern and text block
-1 (int): if there is no mismatch between pattern and text block
"""
for i in range(self.patLen - 1, -1, -1):

View File

@@ -13,12 +13,13 @@ def palindromic_string(input_string):
"""
Manachers algorithm which finds Longest Palindromic Substring in linear time.
1. first this conver input_string("xyx") into new_string("x|y|x") where odd positions are actual input
characters.
1. first this convert input_string("xyx") into new_string("x|y|x") where odd
positions are actual input characters.
2. for each character in new_string it find corresponding length and store,
a. max_length
b. max_length's center
3. return output_string from center - max_length to center + max_length and remove all "|"
3. return output_string from center - max_length to center + max_length and remove
all "|"
"""
max_length = 0
@@ -35,7 +36,7 @@ def palindromic_string(input_string):
# for each character in new_string find corresponding palindromic string
for i in range(len(new_input_string)):
# get palindromic length from ith position
# get palindromic length from i-th position
length = palindromic_length(i, 1, new_input_string)
# update max_length and start position

View File

@@ -1,17 +1,17 @@
def split(string: str, seperator: str = " ") -> list:
def split(string: str, separator: str = " ") -> list:
"""
Will split the string up into all the values seperated by the seperator (defaults to spaces)
Will split the string up into all the values separated by the separator (defaults to spaces)
>>> split("apple#banana#cherry#orange",seperator='#')
>>> split("apple#banana#cherry#orange",separator='#')
['apple', 'banana', 'cherry', 'orange']
>>> split("Hello there")
['Hello', 'there']
>>> split("11/22/63",seperator = '/')
>>> split("11/22/63",separator = '/')
['11', '22', '63']
>>> split("12:43:39",seperator = ":")
>>> split("12:43:39",separator = ":")
['12', '43', '39']
"""
@@ -19,7 +19,7 @@ def split(string: str, seperator: str = " ") -> list:
last_index = 0
for index, char in enumerate(string):
if char == seperator:
if char == separator:
split_words.append(string[last_index:index])
last_index = index + 1
elif index + 1 == len(string):

View File

@@ -11,11 +11,11 @@ def word_occurence(sentence: str) -> dict:
... in Counter(SENTENCE.split()).items())
True
"""
occurence = defaultdict(int)
occurrence = defaultdict(int)
# Creating a dictionary containing count of each word
for word in sentence.split(" "):
occurence[word] += 1
return occurence
occurrence[word] += 1
return occurrence
if __name__ == "__main__":