HOME FORUMS MEMBERS RECENT POSTS LOG IN  
× Авторизация
Имя пользователя:
Пароль:
Нет аккаунта? Регистрация
Баннер 1   Баннер 2
НОВЫЕ ТОРГОВАЯ НОВОСТИ ЧАТ
loading...
Скрыть
Вернуться   Форум АНТИЧАТ > БЕЗОПАСНОСТЬ И УЯЗВИМОСТИ > Беспроводные технологии/Wi-Fi/Wardriving
   
 
 
Опции темы Поиск в этой теме Опции просмотра

  #11  
Старый 05.01.2022, 01:00
Fizzik
Новичок
Регистрация: 29.11.2015
Сообщений: 14
Провел на форуме:
5175

Репутация: 0
По умолчанию

Господа , поделитесь python скриптиком или тулзой для получения отсортированного списка частоты встречи слова в файле, например:

vasya:35

olya:23

nina:12

olga:5

В ExTDv088 этот функционал нерабочий.

Такой скрипт есть, но не знаю как туда сортировку вкорячить:

FILE_NAME = '1.txt'

wordCounter = {}

with open(FILE_NAME,'r') as fh:

for line in fh:

# Replacing punctuation characters. Making the string to lower.

# The split will spit the line into a list.

word_list = line.replace(',','').replace('\'','').replace('.', '').lower().split()

for word in word_list:

# Adding the word into the wordCounter dictionary.

if word not in wordCounter:

wordCounter[word] = 1

else:

# if the word is already in the dictionary update its count.

wordCounter[word] = wordCounter[word] + 1

print('{:15}{:3}'.format('Word','Count'))

print('-' * 18)

# printing the words and its occurrence.

for (word,occurance) in wordCounter.items():

print('{:15}{:3}'.format(word,occurance))
 
Ответить с цитированием
 





Здесь присутствуют: 1 (пользователей: 0 , гостей: 1)
 


Быстрый переход




ANTICHAT ™ © 2001- Antichat Kft.