u4_optim
This commit is contained in:
parent
37e465da2d
commit
6dad46914b
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.test.py
|
||||||
@ -6,10 +6,10 @@ def count_words(sentance: str) -> dict:
|
|||||||
|
|
||||||
SPECIAL_CHAR = oct(7)
|
SPECIAL_CHAR = oct(7)
|
||||||
|
|
||||||
delims = [":", "?", "!", "\n", "\t", ",", ".", "_", '&', '@', '$', '%', '^', '&']
|
delims = ":?!\n\t,._&@$^&*()%"
|
||||||
del_chars = ['"']
|
del_chars = '"'
|
||||||
|
|
||||||
forbidden = delims + del_chars + [" ", "'", ""]
|
forbidden = list(delims) + list(del_chars) + [" ", "'", ""]
|
||||||
|
|
||||||
for i, ch in enumerate(sent_list):
|
for i, ch in enumerate(sent_list):
|
||||||
if(ch in delims):
|
if(ch in delims):
|
||||||
@ -28,5 +28,3 @@ def count_words(sentance: str) -> dict:
|
|||||||
words[w.replace(SPECIAL_CHAR, "'")] += 1
|
words[w.replace(SPECIAL_CHAR, "'")] += 1
|
||||||
|
|
||||||
return dict(words)
|
return dict(words)
|
||||||
|
|
||||||
print(count_words("""seriál: seriálik ako Dunaj: Panelák!!&@$%^&"""))
|
|
||||||
Loading…
Reference in New Issue
Block a user