siddhantuniyal commited on
Commit
5ea0581
1 Parent(s): 225ba06

Upload 2 files

Browse files
Files changed (2) hide show
  1. app.py +157 -0
  2. requirements.txt +2 -0
app.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # import matplotlib.pyplot as plt
2
+ # import nltk
3
+ # import spacy
4
+ # from nltk.sentiment.vader import SentimentIntensityAnalyzer
5
+ from transformers import pipeline
6
+ import gradio as gr
7
+ # # from reportlab.lib.pagesizes import letter
8
+ # # from reportlab.platypus import SimpleDocTemplate, Image
9
+
10
+ # nltk.download('vader_lexicon')
11
+
12
+ # feedbacks = [
13
+ # "I had a great experience with Inspector Sharma during my visit to the police station. He was very helpful and professional.",
14
+ # "My experience at the police station was terrible. The officer on duty was rude and uncooperative.",
15
+ # "I want to express my gratitude to Constable Patel for his prompt response to my complaint. He did an excellent job.",
16
+ # "I appreciate the efforts of Sub-Inspector Khan in solving my case quickly and efficiently. He demonstrated great problem-solving skills.",
17
+ # "I had a bad experience at the police station. Officer Gupta was dismissive and didn't take my complaint seriously.",
18
+ # "I'm thankful to Officer Joshi for helping me with my case. However, the wait time at the police station was excessive, and that needs improvement.",
19
+ # "I would like to acknowledge the hard work of ACP Singh in maintaining law and order in our area. His dedication is commendable.",
20
+ # "My recent interaction with the police station was satisfactory. No complaints, but no exceptional service either.",
21
+ # "I want to express my appreciation to Officer Mehta and Officer Reddy for their quick response to my emergency call. They handled the situation well.",
22
+ # "I had a positive experience at the police station. Constable Gupta was helpful, but there was some confusion regarding the paperwork that could be streamlined.",
23
+ # "My interaction with Officer Kapoor and Officer Sharma was neither good nor bad. It was an average experience with no exceptional service.",
24
+ # "I had a positive experience with Constable Verma. His prompt action was much appreciated.",
25
+ # "I had an unpleasant experience with Officer Kapoor. He was uncooperative and dismissive of my complaint.",
26
+ # "Constable Patel provided exceptional service during my visit to the police station. I was impressed with his professionalism.",
27
+ # "My recent interaction with the police station left much to be desired. The officers seemed disorganized and unresponsive.",
28
+ # "I had a smooth experience at the police station. No complaints, and the staff was polite and efficient.",
29
+ # "I appreciate the dedication of Officer Sharma in ensuring the safety of our community. He is an asset to the police force.",
30
+ # "The service at the police station was disappointing. Officer Gupta was rude and unhelpful.",
31
+ # "I'm grateful to Sub-Inspector Khan for his assistance in resolving my case. He went above and beyond to help me.",
32
+ # "Officer Reddy was exceptionally helpful during my recent visit to the police station. I'm thankful for his support.",
33
+ # "My experience at the police station was unremarkable. The officers did their job, but there was no exceptional service.",
34
+ # "I had a positive experience with Constable Verma, who handled my case with professionalism and efficiency.",
35
+ # "I had a negative experience with Officer Joshi. He was unresponsive and didn't take my concerns seriously.",
36
+ # "The police station needs improvement in terms of service. My recent visit was less than satisfactory.",
37
+ # "I'm satisfied with the service provided by ACP Singh in our area. He ensures our safety and well-being.",
38
+ # "I had a disappointing experience at the police station. The officers were uncooperative and unprofessional.",
39
+ # "I want to acknowledge the hard work of Constable Patel. He is an excellent officer and deserves recognition.",
40
+ # "I had a mixed experience at the police station. Some aspects were positive, while others need improvement.",
41
+ # "Officer Mehta provided prompt and efficient assistance during my visit to the police station. I'm thankful for his support.",
42
+ # "My recent interaction with the police station was average. There were no major issues, but nothing exceptional either."
43
+ # ]
44
+
45
+ # additional_feedbacks = [
46
+ # "Officer Reddy and Officer Joshi were both helpful during my recent visit to the police station. They provided the support I needed.",
47
+ # "I had a positive experience with Officer Mehta and Officer Reddy. Their teamwork was evident in resolving my case.",
48
+ # "Constable Patel and Officer Gupta were uncooperative during my recent visit. The service was disappointing.",
49
+ # "Officer Kapoor's behavior was unprofessional during my visit to the police station. I expected better service.",
50
+ # "I appreciate the assistance of Sub-Inspector Khan and Officer Mehta. They worked together to resolve my complaint.",
51
+ # "I had a negative experience with Constable Patel. He was dismissive and unhelpful.",
52
+ # "Officer Sharma and ACP Singh both played crucial roles in maintaining law and order in our area. Their dedication is commendable.",
53
+ # "My recent interaction with Officer Joshi and Officer Reddy was satisfactory. They handled my concerns efficiently.",
54
+ # "I had an average experience at the police station. Officer Mehta and Constable Verma provided service without any exceptional aspects.",
55
+ # "I had a mixed experience with Officer Gupta and Officer Sharma. While they were professional, the process needs improvement.",
56
+ # ]
57
+ # gujarat_feedbacks = [
58
+ # "I had a positive experience at Gandhinagar Police Station. The officers were helpful and efficient.",
59
+ # "My visit to Ahmedabad Police Station was satisfactory. The staff handled my complaint professionally.",
60
+ # "I appreciate the service at Surat Police Station. They resolved my case promptly.",
61
+ # "Officer Patel at Vadodara Police Station provided exceptional assistance. I'm grateful for their support.",
62
+ # "My recent interaction with Rajkot Police Station was good. They ensured our safety effectively.",
63
+ # "I had a mixed experience at Junagadh Police Station. Some aspects were positive, while others need improvement.",
64
+ # "The police station in Bhavnagar is in need of better service. My recent visit was disappointing.",
65
+ # "I had a positive experience with Officer Mehta at Anand Police Station. Their prompt action was much appreciated.",
66
+ # "I want to acknowledge the hard work of the officers at Jamnagar Police Station. Their dedication is commendable.",
67
+ # "Officer Joshi at Patan Police Station was exceptionally helpful. I'm thankful for their support.",
68
+ # "I had a negative experience at Porbandar Police Station. The officers were unresponsive and unprofessional.",
69
+ # "The police station in Nadiad needs improvement. My recent visit was less than satisfactory.",
70
+ # "I'm satisfied with the service provided by the police in Bharuch, Gujarat. They ensure our safety and well-being.",
71
+ # "I had an unpleasant experience at the police station in Anand. The officers were dismissive and uncooperative.",
72
+ # "Officer Sharma at Vadodara Police Station was professional and efficient. I had a positive experience.",
73
+ # "I had a smooth experience at the police station in Rajkot. No complaints, and the staff was polite and efficient.",
74
+ # "I appreciate the dedication of the officers at Surat Police Station. They maintain law and order effectively.",
75
+ # "My experience at the police station in Bhuj was unremarkable. The officers did their job, but there was no exceptional service.",
76
+ # "I want to express my gratitude to the officers at Bhavnagar Police Station for their prompt response to my complaint.",
77
+ # "Officer Desai at Porbandar Police Station was helpful and professional during my visit. I had a good experience.",
78
+ # "My recent interaction with the police in Jamnagar was satisfactory. The officers handled my concerns efficiently.",
79
+ # "The service at Bhuj Police Station was disappointing. Officer Shah was unhelpful and rude during my visit.",
80
+ # "I'm thankful to Officer Patel at Gandhinagar Police Station for helping me with my case. Their prompt response was appreciated.",
81
+ # "My visit to the police station in Anand, Gujarat, was terrible. The officer on duty was dismissive and uncooperative.",
82
+ # "Officer Pandya at Junagadh Police Station provided excellent assistance. I want to express my gratitude for their support.",
83
+ # "My recent interaction with the police in Surat was less than satisfactory. The officers seemed disorganized and unresponsive.",
84
+ # "I had a good experience at Rajkot Police Station. The officers were professional and handled my case effectively.",
85
+ # "I had an average experience at the police station in Gandhinagar. The service was neither good nor bad.",
86
+ # "The police station in Bharuch needs improvement. My recent visit was disappointing, and the service was lacking.",
87
+ # "Officer Mehta at Bhavnagar Police Station was helpful and professional. I appreciate their dedication to their job.",
88
+ # "I had a mixed experience at Ahmedabad Police Station. Some aspects were positive, while others need improvement.",
89
+ # "I'm grateful for the service provided by the police in Vadodara, Gujarat. They ensure the safety of our community.",
90
+ # ]
91
+
92
+ # feedbacks += gujarat_feedbacks
93
+
94
+
95
+ # feedbacks += additional_feedbacks
96
+
97
+ issues = ["Misconduct" , "Negligence" , "Discrimination" , "Corruption" , "Violation of Rights" , "Inefficiency" ,
98
+ "Unprofessional Conduct", "Response Time" , "Use of Firearms" , "Property Damage"]
99
+
100
+
101
+ groupByType = pipeline("zero-shot-classification" , model="facebook/bart-large-mnli")
102
+
103
+
104
+
105
+ # pos_count = 0
106
+ # neg_count = 0
107
+ # neutral_count = 0
108
+
109
+
110
+ # report = {}
111
+
112
+
113
+
114
+ # ner = spacy.load("en_core_web_sm")
115
+
116
+ # for feedback in feedbacks:
117
+ # # location = ""
118
+ # # doc = ner(feedback)
119
+ # # for ent in doc.ents:
120
+ # # if ent.label_=='GPE':
121
+ # # location = ent.text.lower()
122
+ # # if location not in report:
123
+ # # report[location] = [[0,0,0] , []]
124
+
125
+ # # if location:
126
+
127
+ # # score = SentimentIntensityAnalyzer().polarity_scores(feedback)
128
+ # # sentiment = max(score , key = score.get)
129
+ # # if sentiment == 'pos':
130
+ # # report[location][0][0]+=1
131
+ # # elif sentiment == 'neg':
132
+ # # report[location][0][1]+=1
133
+ # # else:
134
+ # # report[location][0][2]+=1
135
+
136
+ # # report[location][1].append(groupByType(feedback , candidate_labels = issues)['labels'][0])
137
+ # report[feedback] = groupByType(feedback , candidate_labels = issues)['labels'][0]
138
+
139
+
140
+
141
+
142
+ # # print(report)
143
+
144
+
145
+
146
+ def zeroshotclassification(feedback):
147
+ issue = groupByType(feedback , candidate_labels = issues)['labels'][0]
148
+ return issue
149
+
150
+ iface = gr.Interface(
151
+ fn=zeroshotclassification,
152
+ inputs=[
153
+ "text"
154
+ ],
155
+ outputs=["text"]
156
+ )
157
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ transformers
2
+ gradio