-
Notifications
You must be signed in to change notification settings - Fork 0
/
excluindo.py
42 lines (40 loc) · 1.3 KB
/
excluindo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
from nltk.util import ngrams
from collections import Counter
import os
num=1
count = 0
Oldroot = ''
categoria = ''
Estadao = open('excluir-Estadão.txt', 'r')
Folha = open('excluir-Folha.txt', 'r')
Tudo = open('excluir-tudo.txt', 'r')
LinesTudo = Tudo.readlines()
LinesFolha = Folha.readlines()
LinesEstadao = Estadao.readlines()
for root, dirs, files in os.walk('notícias/resultados-filtro-automatico'):
for file in files:
for line in LinesFolha:
filename, extension = os.path.splitext(file)
size = len(root.split('/'))
rootbegin = root.split('/')[2:size]
ano = rootbegin[0]
jornal = rootbegin[1]
keyword = rootbegin[2] #.split('-')[1]
if('Estadão' in root): #Estadão ou Folha
count+=1
continue
try:
categoria = rootbegin[3]
except:
pass
rootbegin = "/".join(rootbegin)
if(f'{categoria}\n' == line and root!=Oldroot):
Oldroot = root
print(f'{num}! - {root}')
for file in files:
os.remove(f'{root}/{file}')
try:
os.rmdir(root)
except:
pass
num+=1