Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def find_txt_files(directory, lowercase, dictionary_stat):
- # Поиск .txt файлов в директории
- # directory - директория с файлами для обучения
- # lowercase - переменная, отвечающая за приведение слов, сохраняемых
- # в модели, к нижнему регистру
- # dictionary_stat - словарь с моделью
- # ---------------------------------------------------------------- #
- # Поиск файлов в директории
- for top, dirs, files in os.walk(directory):
- for i in files:
- # Путь к файлу
- path = str(os.path.join(top, i))
- # Разделяем имя файла на 2 части: заголовок и формат
- filename, file_extension = os.path.splitext(path)
- # Если .тхт, то обрабатываем его
- if file_extension == '.txt':
- # Обрабатываемый файл
- file = str(os.path.normpath(path))
- train(file, lowercase, dictionary_stat)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement