Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from collections import Counter
- text = "11011111" # Ваш бинарный текст, вставь сюда свою строку из 1500 символов
- ngram_frequencies = {}
- # Перебираем n от 1 до 10
- for n in range(1, 11):
- ngrams_list = [text[i:i + n] for i in range(len(text) - n + 1)]
- ngram_frequency = Counter(ngrams_list)
- ngram_frequencies[n] = ngram_frequency
- for n, frequency in ngram_frequencies.items():
- print(f"n = {n}")
- sorted_frequency = frequency.most_common()
- for ngram, count in sorted_frequency:
- print(ngram, ";", count,";",f"{round((count/len(text)*100),2)}%")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement