Загружаю решение задачи с функцией word_count
This commit is contained in:
parent
e4c2142663
commit
16995087ba
|
@ -1,7 +1,9 @@
|
|||
import re
|
||||
import numpy as np
|
||||
|
||||
|
||||
def word_count(text):
|
||||
c = []
|
||||
import re
|
||||
import numpy as np
|
||||
final = {}
|
||||
a = re.sub("[^А-Яа-я-A-Z-a-z ]", "", text).lower()
|
||||
b = str(a).split()
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
import re
|
||||
import numpy as np
|
||||
|
||||
def verify(message, expected, actual):
|
||||
a = "========================="
|
||||
print(a)
|
||||
|
@ -13,8 +16,6 @@ def verify(message, expected, actual):
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
def verify_all(dataset):
|
||||
summa_success = int()
|
||||
summa_failed = int()
|
||||
|
@ -46,10 +47,26 @@ def max_array(array):
|
|||
|
||||
|
||||
|
||||
array = [2, 3, 5, 8, 89, 65, 75,7895, 2, 1, 1]
|
||||
def word_count(text):
|
||||
c = []
|
||||
final = {}
|
||||
a = re.sub("[^А-Яа-я-A-Z-a-z ]", "", text).lower()
|
||||
b = str(a).split()
|
||||
c = list(b)
|
||||
unique_array, count_array = np.unique(c, return_counts=True)
|
||||
final = zip(unique_array, count_array)
|
||||
final2 = list(final)
|
||||
return final2
|
||||
|
||||
|
||||
dataset = [("Test1", 3, min_array(array)), ("Test2", 7895, max_array(array))]
|
||||
|
||||
f = 'Я пришел, я ушел, я нашел'
|
||||
|
||||
array = [2, 3, 5, 8, 89, 65, 75, 7895, 2, 1, 1]
|
||||
|
||||
|
||||
dataset = [("Test1", 3, min_array(array)), ("Test2", 7895, max_array(array)),
|
||||
("Test3", [('нашел', 1), ('пришел', 1), ('ушел', 1), ('я', 3)], word_count(f))]
|
||||
|
||||
|
||||
verify_all(dataset)
|
||||
|
|
Loading…
Reference in New Issue