Update app.py
Browse files
app.py
CHANGED
@@ -42,31 +42,34 @@ q[2] = "What time is it going to happen?"
|
|
42 |
QA_input = [{} for i in range(3)]
|
43 |
res = [{} for i in range(3)]
|
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 |
-
|
|
|
|
|
|
|
|
42 |
QA_input = [{} for i in range(3)]
|
43 |
res = [{} for i in range(3)]
|
44 |
|
45 |
+
df = pd.read_excel('senti.xlsx')
|
46 |
+
|
47 |
+
parsed_column = df['sentences'].to_list()
|
48 |
+
|
49 |
+
print(parsed_column)
|
50 |
+
for sentence in parsed_column:
|
51 |
+
for i in range(3):
|
52 |
+
QA_input[i] = {
|
53 |
+
'question': q[i],
|
54 |
+
'context': sentence
|
55 |
+
}
|
56 |
+
res[i] = nlp(QA_input[i])
|
57 |
+
a[i] = res[i]['answer']
|
58 |
+
|
59 |
+
a1 = a[0].lower()
|
60 |
+
a1s = set(a1.split())
|
61 |
+
sus = set(suspicious_words)
|
62 |
+
cw = a1s.intersection(sus)
|
63 |
+
|
64 |
+
if len(cw) != 0:
|
65 |
+
st.write("The crime detected is: ",a[0])
|
66 |
+
if len(a[1]) != 0:
|
67 |
+
st.write("The location of crime detected is: ",a[1])
|
68 |
+
elif len(a[1]) == 0:
|
69 |
+
st.write("No location detected")
|
70 |
+
if len(a[2]) != 0:
|
71 |
+
st.write("The time of crime detected is: ",a[2])
|
72 |
+
elif len(a[2]) == 0:
|
73 |
+
st.write("No time detected")
|
74 |
+
elif len(cw) == 0:
|
75 |
+
st.write("No crime detected")
|