hnc-eduard/HNS/Excercises/04072023 Определить количес.../main.py

21 lines
403 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import re
import numpy as np
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
f = 'Я пришел, я ушел, я нашел'
print(word_count(f))