Skip to content

Commit 34c2b1c

Browse files
author
BB
committed
-
1 parent 8c4061c commit 34c2b1c

File tree

1 file changed

+4
-32
lines changed

1 file changed

+4
-32
lines changed

invidx.py

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
from unidecode import unidecode
44

55
WORD = re.compile(r'\w+')
6-
target_dir = "/home/burak/Documents/repos/burakbayramli.github.com"
6+
#target_dir = "/home/burak/Documents/repos/burakbayramli.github.com"
7+
target_dir = "/tmp"
78
topdirs = ['algs','calc_multi','chaos','compscieng','func_analysis','linear','ode', 'stat','tser','vision','phy']
89

910
def clean_text(text):
@@ -70,40 +71,11 @@ def index_dir():
7071
invidx_dict[first_letter][k] = v
7172

7273
for k,v in invidx_dict.items():
73-
fout = open(target_dir + "/idx/invidx-%s.json" % k,"w")
74+
fout = open(target_dir + "/invidx-%s.json" % k,"w")
7475
fout.write(json.dumps(v))
7576
fout.close()
76-
77-
def test1():
78-
res = util.get_title_from_tex('algs/algs_045_probsolve/algs_045_probsolve.tex')
79-
print (res)
80-
print (util.filename_from_title(res))
81-
82-
83-
def test2():
84-
#search = "green teorisi"
85-
search = "convnet"
86-
stok = search.split()
87-
stok_hits = {}
88-
results = []
89-
for tok in stok:
90-
stok_hits[tok] = json.loads(open(target_dir + "/idx/invidx-%s.json" % tok[0]).read())[tok]
91-
results.append(set(stok_hits[tok]))
92-
93-
u = set.intersection(*results)
94-
95-
hits = []
96-
for f in u:
97-
hits.append([f,sum([stok_hits[tok][f] for tok in stok])])
98-
99-
sorted_hits = sorted(range(len(hits)), key=lambda x: hits[x][1], reverse=True)
100-
N = min(20,len(hits))
101-
for i in range(N):
102-
print (hits[sorted_hits[i]][0])
103-
10477

10578
if __name__ == "__main__":
10679

107-
#index_dir()
108-
test2()
80+
index_dir()
10981

0 commit comments

Comments
 (0)