-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
76 lines (58 loc) · 2.12 KB
/
main.py
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
from flask import *
import os
import src.classes.genrateFiles
import src.classes.statisticalModel
import src.classes.vectorSpaceModel
app = Flask(__name__)
@app.route('/')
def index():
return render_template('index.html')
@app.route('/generateFilesStatModel', methods=['GET'])
def generateFilesStatModel():
if request.method == "GET":
obj = src.classes.genrateFiles.GenrateFile(10)
obj.mix("ABCDEF", 100, 250)
return redirect(url_for('index'))
@app.route('/generateFilesVectorModel', methods=['GET'])
def generateFilesVectorModel():
if request.method == "GET":
obj = src.classes.genrateFiles.GenrateFile(10)
obj.mix("ABCDEF", 1, 10)
return redirect(url_for('index'))
@app.route('/statisticalModel', methods=['POST', 'GET'])
def statisticalModelFunc():
obj1 = src.classes.statisticalModel.StatisticalModel("ABCDEF")
IsWeighted = ""
if request.method == "POST":
query = request.form['search']
IsWeighted = request.form['weight']
else:
query = request.args.get['search']
if IsWeighted == "True":
if obj1.prepareWeightQuery(query) == 0:
return redirect(url_for('index'))
else:
obj1.prepareUnWeightQuery(query)
obj1.structureOfModel()
results = obj1.dotProduct()
return render_template('results.html', results=results, model="statistical Model")
@app.route('/vectorSpaceModel', methods=['POST', 'GET'])
def vectorSpaceModel():
obj1 = src.classes.vectorSpaceModel.VectorSpaceModel("ABCDEF")
obj1.tfDocuments()
obj1.idfCalculation()
obj1.weightCalculation()
if request.method == "POST":
query = request.form['search']
else:
query = request.args.get['search']
obj1.querySet(query)
results = obj1.cosineSimilarity()
return render_template('results.html', results=results, model="vector-space Model")
@app.route('/document/<document>')
def showContentOfDocument(document):
filtered = open(os.path.join(os.path.join(os.path.curdir, "Documents"), document), 'r')
content = filtered.read()
return '%s' % content
if __name__ == '__main__':
app.run()