-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
32 lines (27 loc) · 1.01 KB
/
main.py
File metadata and controls
32 lines (27 loc) · 1.01 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
from whoosh.qparser import *
from whoosh.fields import Schema, TEXT, KEYWORD, ID, STORED, NUMERIC
from whoosh.analysis import StemmingAnalyzer, StandardAnalyzer
from whoosh import index
from whoosh.index import create_in
import os, os.path
import json
from pydf import myPaper
from pydf import db
db.create_all()
file_dir = '/Users/tony/Desktop/search_engine/filedir/'
file_name = os.listdir(file_dir)
print(len(file_name))
# reading files and put them into database
file_load = json.load(open('/Users/tony/Desktop/search_engine/filedir/arxivData.json', 'r'))
for i in range(len(file_load)):
if (i%1000) == 0:
print("%s files loaded" % (i))
new_input = myPaper(
id = file_load[i]['id'],
title = file_load[i]['title'],
abstract=file_load[i]['summary'],
author=file_load[i]['author'],
link=file_load[i]['link']
)
db.session.add(new_input)
db.session.commit()