so'zlarni sanashda tinish belgilarini ajratib turadigan va
vaziyatni e'tiborsiz qoldiradigan yana bir regeks hal. Umumiy
so'zlar soni yoki noyob so'zlar sonini xohlaysizmi, amin emasman,
shuning uchun ham men ...
So'zlarni hisoblash uchun so'zlar va
collections.Counter so'zlarini topish uchun kerakli
r "\ w +" .
text = """A Turing machine is a device that manipulates symbols on a strip of tape according to a table of rules. Despite its simplicity, a Turing machine can be adapted to simulate the logic of any computer algorithm, and is particularly useful in explaining the functions of a CPU inside a computer. The "Turing" machine was described by Alan Turing in 1936, who called it an "a(utomatic)-machine". The Turing machine is not intended as a practical computing technology, but rather as a hypothetical device representing a computing machine. Turing machines help computer scientists understand the limits of mechanical computation."""
print("Number of words:", sum(1 for _ in re.finditer(r"\w+", text)))
unique_words = collections.Counter(match.group(0).lower() for match in re.finditer(r"\w+", text))
print("Number of unique words:", len(unique_words))
print("Unique words:", ', '.join(sorted(unique_words)))
print("Number of sentences:", sum(1 for _ in re.finditer(r"\.", text)))
$ python3 test.py
Number of words: 100
Number of unique words: 63
Unique words: 1936, a, according, adapted, alan, algorithm, an, and, any, as, be, but, by, called, can, computation, computer, computing, cpu, described, despite, device, explaining, functions, help, hypothetical, in, inside, intended, is, it, its, limits, logic, machine, machines, manipulates, mechanical, not, of, on, particularly, practical, rather, representing, rules, scientists, simplicity, simulate, strip, symbols, table, tape, technology, that, the, to, turing, understand, useful, utomatic, was, who
Number of sentences: 5