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