-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYYY.py
More file actions
39 lines (32 loc) · 1.09 KB
/
Copy pathYYY.py
File metadata and controls
39 lines (32 loc) · 1.09 KB
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
class Corretor():
def __init__(self,in_name_arquivo = None):
self.name_arquivo = in_name_arquivo
self.creat_dict()
def le_arquivo (self):
f = open(self.name_arquivo,'r') # sai zoado pq tem que codificar direito
lines = f.readlines()
lines = [line.rstrip('\n') for line in lines]
return(lines)
def creat_dict(self):
lines = self.le_arquivo()
dict={}
for test_str in lines:
dict1 = {test_str[0:i]+test_str[i+1:]: test_str for i in range (len(test_str))}
dict.update(dict1)
return dict
def sugere(self, palavra):
dict = self.creat_dict()
sugerida = ""
for i in dict:
if palavra == i:
sugerida = dict[i]
break
elif palavra == dict[i]:
sugerida = palavra
break
return sugerida
#x = Corretor('corpus.txt')
#lines = x.le_arquivo()
#dictt = x.creat_dict()
#teste = x.sugere('palara')
#print(teste)