qanastek commited on
Commit
04740c6
·
1 Parent(s): 8abcde8

Update PxCorpus.py

Browse files
Files changed (1) hide show
  1. PxCorpus.py +6 -5
PxCorpus.py CHANGED
@@ -43,23 +43,24 @@ class StringIndex:
43
  self.vocab_struct = {}
44
 
45
  print("Start building the index!")
46
- for term in vocab:
47
 
48
- if len(term) == 0:
49
  continue
50
 
51
  # Index terms by their first letter and length
52
- key = (term[0], len(term))
53
 
54
  if key not in self.vocab_struct:
55
  self.vocab_struct[key] = []
56
 
57
- self.vocab_struct[key].append(term)
58
 
59
  print("Finished building the index!")
60
 
61
  def find(self, t):
62
- return t in self.vocab_struct[(t[0], len(str(t)))]
 
63
 
64
  _VOCAB = StringIndex(vocab=open("./vocabulary_nachos_lowercased.txt","r").read().split("\n"))
65
 
 
43
  self.vocab_struct = {}
44
 
45
  print("Start building the index!")
46
+ for t in vocab:
47
 
48
+ if len(t) == 0:
49
  continue
50
 
51
  # Index terms by their first letter and length
52
+ key = (t[0], len(t))
53
 
54
  if key not in self.vocab_struct:
55
  self.vocab_struct[key] = []
56
 
57
+ self.vocab_struct[key].append(t)
58
 
59
  print("Finished building the index!")
60
 
61
  def find(self, t):
62
+ key = (t[0], len(t))
63
+ return t in self.vocab_struct[key]
64
 
65
  _VOCAB = StringIndex(vocab=open("./vocabulary_nachos_lowercased.txt","r").read().split("\n"))
66