-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
166 lines (129 loc) · 5.65 KB
/
app.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
#!/usr/bin/env python
__author__ = "Akalanka Galappaththi"
__email__ = "[email protected]"
__copyright__ = "Copyright 2020, The Bug Report Summarization Project @ Sybil-Lab"
__license__ = "MIT"
__maintainer__ = "Akalanka Galappaththi"
from flask import Flask, render_template, request, redirect, url_for
from dotenv import load_dotenv
import os
import json
from jinja2 import Template
from controllers.BugReportController import BugReportController
from controllers.OTFController import OTFController
from controllers.RSFController import RSFController
from controllers.URLController import URLController
from controllers.CWController import CWController
# from controllers.CFGController import CFGController
from controllers.SyntaxController import SyntaxController
from controllers.TopicModelController import TopicModelController
from controllers.DescriptionController import DescriptionController
from controllers.TextCleanController import TextCleanController
from view.Display import Display
# load .env file
load_dotenv()
app = Flask(__name__)
app.config.from_object(os.environ['APP_SETTINGS'])
@app.route('/', methods=['GET','POST'])
def display():
# create a ListOfBugReport object and get the list
bugs = BugReportController().createBugReport()
list_of_bugs = bugs.get_list_of_bugs()
# list index selector
i = 0
# create controller objects
otc = OTFController()
rsc = RSFController()
urlc = URLController()
# cfgc = CFGController()
syc = SyntaxController()
tmc = TopicModelController()
tcc = TextCleanController()
for turn in list_of_bugs[i].get_turns():
for sent in turn.get_sentences():
# cfgc.setSentenceType(sent)
urlc.findURL(sent)
syc.findSyntax(sent)
otc.findOTComment(sent)
# Need a separate loop since the first comment doesn't have resolution sentences
for turn in list_of_bugs[i].get_turns():
if turn.get_id() == 1:
continue
for sent in turn.get_sentences():
rsc.findRSComments(sent)
# find clue word related links between comments/turns
cwc = CWController()
cwc.findLinks(list_of_bugs[i])
# find topic words in sentences
topics = tmc.extractTopics(list_of_bugs[i])
tmc.findTopicWordMatches(list_of_bugs[i], topics)
# find steps to reproduce, expected results and actual results in the first comment
dc = DescriptionController()
for turn in list_of_bugs[i].get_turns():
if turn.get_id() == 1:
dc.findBugDescription(turn, list_of_bugs[i].get_title())
break
# run all sentences through TextCleanController to make a better display of sentences
for turn in list_of_bugs[i].get_turns():
for sent in turn.get_sentences():
sent.set_cleaned_text(tcc.clean_sentence(sent.get_text(), r_digit=False, r_punc=False, stop=False, lem=False, escape=True))
# call the display option after running automatic labeling
bug_data = Display().getBugReportJson(list_of_bugs[i], ct=True)
deserialized_bug_data = json.loads(bug_data)
# sanity check for list of turns
# print(deserialized_bug_data['list_of_turns'])
# createa jinja template
return render_template('display.html', response = deserialized_bug_data)
@app.route('/select', methods=['GET','POST'])
def selectDisplay():
# create a ListOfBugReport object and get the list
bugs = BugReportController().createBugReport()
list_of_bugs = bugs.get_list_of_bugs()
# list index selector
i = int(request.args.get('id'))
# print(i)
# create controller objects
otc = OTFController()
rsc = RSFController()
urlc = URLController()
# cfgc = CFGController()
syc = SyntaxController()
tmc = TopicModelController()
tcc = TextCleanController()
for turn in list_of_bugs[i].get_turns():
for sent in turn.get_sentences():
# cfgc.setSentenceType(sent)
urlc.findURL(sent)
syc.findSyntax(sent)
otc.findOTComment(sent)
# Need a separate loop since the first comment doesn't have resolution sentences
for turn in list_of_bugs[i].get_turns():
if turn.get_id() == 1:
continue
for sent in turn.get_sentences():
rsc.findRSComments(sent)
# find clue word related links between comments/turns
cwc = CWController()
cwc.findLinks(list_of_bugs[i])
# find topic words in sentences
topics = tmc.extractTopics(list_of_bugs[i])
tmc.findTopicWordMatches(list_of_bugs[i], topics)
# find steps to reproduce, expected results and actual results in the first comment
dc = DescriptionController()
for turn in list_of_bugs[i].get_turns():
if turn.get_id() == 1:
dc.findBugDescription(turn, list_of_bugs[i].get_title())
break
# run all sentences through TextCleanController to make a better display of sentences
for turn in list_of_bugs[i].get_turns():
for sent in turn.get_sentences():
sent.set_cleaned_text(tcc.clean_sentence(sent.get_text(), r_digit=False, r_punc=False, stop=False, lem=False, escape=True))
# call the display option after running automatic labeling
bug_data = Display().getBugReportJson(list_of_bugs[i])
deserialized_bug_data = json.loads(bug_data)
# sanity check for list of turns
# print(deserialized_bug_data['list_of_turns'])
# createa jinja template
return render_template('display.html', response = deserialized_bug_data)
if __name__ == '__main__':
app.run()