2020-06-05 18:22:20 +00:00
|
|
|
from .word_count import search, search_sequential, search_sequential_allow_threads
|
2017-07-26 04:37:36 +00:00
|
|
|
|
2020-06-05 18:22:20 +00:00
|
|
|
__all__ = [
|
|
|
|
"search_py",
|
|
|
|
"search",
|
|
|
|
"search_sequential",
|
|
|
|
"search_sequential_allow_threads",
|
|
|
|
]
|
2017-07-26 04:37:36 +00:00
|
|
|
|
|
|
|
|
2021-08-13 13:00:29 +00:00
|
|
|
def search_py(contents: str, needle: str) -> int:
|
2017-07-26 04:37:36 +00:00
|
|
|
total = 0
|
2021-08-13 13:00:29 +00:00
|
|
|
for line in contents.splitlines():
|
|
|
|
for word in line.split(" "):
|
2020-06-05 12:33:15 +00:00
|
|
|
if word == needle:
|
|
|
|
total += 1
|
2017-07-26 04:37:36 +00:00
|
|
|
return total
|