Update PxCorpus.py
Browse files- 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
|
47 |
|
48 |
-
if len(
|
49 |
continue
|
50 |
|
51 |
# Index terms by their first letter and length
|
52 |
-
key = (
|
53 |
|
54 |
if key not in self.vocab_struct:
|
55 |
self.vocab_struct[key] = []
|
56 |
|
57 |
-
self.vocab_struct[key].append(
|
58 |
|
59 |
print("Finished building the index!")
|
60 |
|
61 |
def find(self, t):
|
62 |
-
|
|
|
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 |
|