Tejasw1 commited on
Commit
22e1e71
1 Parent(s): c810662

Upload folder using huggingface_hub

Browse files
Files changed (5) hide show
  1. .gitattributes +2 -67
  2. Apr.csv +2 -2
  3. __pycache__/gradio_app.cpython-311.pyc +0 -0
  4. gradio_app.py +43 -17
  5. test.py +20 -0
.gitattributes CHANGED
@@ -1,67 +1,2 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
36
- venv/bin/python filter=lfs diff=lfs merge=lfs -text
37
- venv/bin/python3 filter=lfs diff=lfs merge=lfs -text
38
- venv/bin/python3.11 filter=lfs diff=lfs merge=lfs -text
39
- venv/lib/python3.11/site-packages/PIL/_imaging.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
40
- venv/lib/python3.11/site-packages/altair/vegalite/v5/schema/__pycache__/channels.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
41
- venv/lib/python3.11/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-311.pyc filter=lfs diff=lfs merge=lfs -text
42
- venv/lib/python3.11/site-packages/numpy/core/_multiarray_umath.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
43
- venv/lib/python3.11/site-packages/numpy/core/_simd.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
44
- venv/lib/python3.11/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
45
- venv/lib/python3.11/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so filter=lfs diff=lfs merge=lfs -text
46
- venv/lib/python3.11/site-packages/pandas/_libs/algos.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
47
- venv/lib/python3.11/site-packages/pandas/_libs/groupby.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
48
- venv/lib/python3.11/site-packages/pandas/_libs/hashtable.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
49
- venv/lib/python3.11/site-packages/pandas/_libs/interval.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
50
- venv/lib/python3.11/site-packages/pandas/_libs/join.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
51
- venv/lib/python3.11/site-packages/pandas/_libs/tslibs/offsets.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
52
- venv/lib/python3.11/site-packages/pillow.libs/libfreetype-f154df84.so.6.20.1 filter=lfs diff=lfs merge=lfs -text
53
- venv/lib/python3.11/site-packages/pillow.libs/libharfbuzz-2093a78b.so.0.60830.0 filter=lfs diff=lfs merge=lfs -text
54
- venv/lib/python3.11/site-packages/pyarrow/_compute.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
55
- venv/lib/python3.11/site-packages/pyarrow/_dataset.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
56
- venv/lib/python3.11/site-packages/pyarrow/_flight.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
57
- venv/lib/python3.11/site-packages/pyarrow/lib.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
58
- venv/lib/python3.11/site-packages/pyarrow/libarrow.so.1500 filter=lfs diff=lfs merge=lfs -text
59
- venv/lib/python3.11/site-packages/pyarrow/libarrow_acero.so.1500 filter=lfs diff=lfs merge=lfs -text
60
- venv/lib/python3.11/site-packages/pyarrow/libarrow_dataset.so.1500 filter=lfs diff=lfs merge=lfs -text
61
- venv/lib/python3.11/site-packages/pyarrow/libarrow_flight.so.1500 filter=lfs diff=lfs merge=lfs -text
62
- venv/lib/python3.11/site-packages/pyarrow/libarrow_python.so filter=lfs diff=lfs merge=lfs -text
63
- venv/lib/python3.11/site-packages/pyarrow/libarrow_substrait.so.1500 filter=lfs diff=lfs merge=lfs -text
64
- venv/lib/python3.11/site-packages/pyarrow/libparquet.so.1500 filter=lfs diff=lfs merge=lfs -text
65
- venv/lib/python3.11/site-packages/pydantic_core/_pydantic_core.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
66
- venv/lib/python3.11/site-packages/rpds/rpds.cpython-311-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
67
- Apr.csv filter=lfs diff=lfs merge=lfs -text
 
1
+ *..csv filter=lfs diff=lfs merge=lfs -text
2
+ *.csv filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
Apr.csv CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:4bc09d1274c0b59e8cae97dd8c66e749178ce1706d9e2cd19a7fbb5fc94f7025
3
- size 249616475
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e59ae71345be83097e3f15b437541a1a1f0c68c17b280b87de966c6e066bffcd
3
+ size 134
__pycache__/gradio_app.cpython-311.pyc CHANGED
Binary files a/__pycache__/gradio_app.cpython-311.pyc and b/__pycache__/gradio_app.cpython-311.pyc differ
 
gradio_app.py CHANGED
@@ -2,12 +2,14 @@ import requests, uuid, json
2
  from openai import AzureOpenAI,OpenAI
3
  import re
4
  import gradio as gr
 
 
5
 
6
- client = AzureOpenAI(
7
- api_key="e5a86e5ac7ce453a8fae2dcbfaafbef7",
8
- api_version="2023-07-01-preview",
9
- azure_endpoint="https://votum.openai.azure.com/",
10
- )
11
 
12
  mistral_client = OpenAI(
13
  api_key='EMPTY',
@@ -22,9 +24,9 @@ You should to showcase creativity and knowledge to enhance the accuracy of statu
22
 
23
  Context:
24
  -----
25
- Fact Statement:"Nakal Tahrir Hindi Plaintiff Service in Mr. SHO Sir Police Station Akrawad District Aligarh Sir, today on 24/4/2021, I along with Deputy Inspector Kapil Dev Maya Hamrah Ka0 406 Narsingh was in the police station area in the police station area to effectively follow the preventive action and public to follow the public in connection with the election. Ravindra Giri, a candidate for the post of panchayat member, along with his supporters, has violated the rules of code of conduct and public care by violating Section 144 CrPC by violating Section 144 CrPC by violating the campaign vehicle UP 86 T 5771 MAX without any permission in his favor with his supporters. In which there was full possibility of spreading the infection, the documents of the said vehicle were asked from the candidate Ravindra Giri, then the vehicle number UP 86 T 5771 was seized under section 207 MV Act and Gavendra Giri son of Moti Giri and Jitendra Giri son of Ramprakash Giri and Gaurav Giri son of Jugendra Giri Ni0 Gana Kathera police station Vijaygarh district Aligarh and Yogesh Kumar son of Rajendra Singh Ni0wari police station Vijaygarh district Aligarh The offence of IPC reaches the extent of Section 188/269/171 C IPC and Epidemic Act. Sir, I request you to please register a case against the said accused and take necessary action. S.C. English U.P. Kapil Dev 24/4/21 Kapil Dev SI PS Akrawad Aligarh In the note CC 686 Yashpal Singh certifies that the copy of Tahrir has been marked as word and word."
26
 
27
- Statutes:['IPC_188', 'IPC_269', 'IPC_171C', 'The_Motor_Vehicles_Act_1988_207']
28
  -----
29
 
30
  ###
@@ -36,8 +38,7 @@ Instructions:
36
 
37
  Learn from the examples provided in the context to understand the task of charge or statute prediction.
38
  Your response should be focused on providing the exact statute or charge that aligns with the legal principles and precedents applicable to the given facts.
39
- In your response, include only the statutes you are most confident about.Ensure that the statutes generated as responses are valid and recognized legal statutes appliable in FIRs like IPC or special acts like The_Arms_Act_27, Protection_of_Children_from_Sexual_Offenses_Act_2012, Motor_Vehicles_Act etc. Avoid generating fabricated or invalid statutes.
40
- The model's performance will be evaluated based on its ability to predict the correct statute, include only confident statutes, and showcase creativity in its predictions.
41
  Think step by step to cover all possible statutes that are relevant to the fact statement.
42
 
43
  Fact Statement: ```{fact}```
@@ -102,23 +103,48 @@ def translate(text):
102
  request = requests.post(constructed_url, params=params, headers=headers, json=body)
103
  return request.json()[0]['translations'][0]['text']
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  def predict_statutes(fir_text,language):
106
  if language == 'Hindi':
107
  text = translate(fir_text)
108
  else:
109
  text = fir_text
110
-
 
 
111
  if text:
112
  gpt_output = generate(text)
113
  statutes_list = extract_statutes(gpt_output)
114
  if statutes_list:
115
- return "\n".join(f"- {statute}" for statute in statutes_list)
116
  else:
117
- return "No statutes were predicted. Please check the FIR text and try again."
118
  else:
119
- return "Please enter the FIR text to predict statutes."
120
-
121
- # Gradio app layout
122
  demo = gr.Interface(
123
  title='Statute Prediction',
124
  description='Uses AI to analyze the FIR content and intelligently predict applicable statutes',
@@ -127,8 +153,8 @@ demo = gr.Interface(
127
  gr.Dropdown(label="Select Language", choices=["English", "Hindi"], value="English"),
128
  # gr.Slider(minimum=0.1,maximum=1.0,value=0.5,step=0.1),
129
  ],
130
- outputs=gr.Textbox(label="Predicted Statutes"),
131
- examples=[[fact_example, "English"]],
132
  )
133
 
134
  demo.launch()
 
2
  from openai import AzureOpenAI,OpenAI
3
  import re
4
  import gradio as gr
5
+ import csv
6
+ import random
7
 
8
+ # client = AzureOpenAI(
9
+ # api_key="e5a86e5ac7ce453a8fae2dcbfaafbef7",
10
+ # api_version="2023-07-01-preview",
11
+ # azure_endpoint="https://votum.openai.azure.com/",
12
+ # )
13
 
14
  mistral_client = OpenAI(
15
  api_key='EMPTY',
 
24
 
25
  Context:
26
  -----
27
+ Fact Statement:"Copying Tahrir Hindi plaintiff ................... In service Mr. SHO Akrabad Aligarh The request is that I am Rahul Kumar S/0 Gopal resident of Vijaygarh Chauraha Police Station Akrabad Aligarh, today on 30/4/2021 at around 7 o'clock in the evening I was sitting at my coke shop, Deepu, Kalu, Karthik, Dinesh, Saunu, came to me and started saying that you ask for a lot of money, now tell you that then the above people called their colleagues and called And all of them unanimously started beating me and my sister Neelam, due to which my sister's clothes were torn, hearing the noise, Ramu Sunil, many people came from nearby, then all these people started running threatening to kill and then Kalu S/0 Dinanath resident of Kuagaon, Karthik S/0 Devendra, Deepu fired at me with the intention of killing me, in which a fire has hit the thumb of my left hand, due to which I have suffered a lot of injury and bleeding, so I request sir to please file my report Signature Rahul Applicant Rahul S/0 Gopal R/o Vijaygarh Chauraha Police Station Akhrabad Aligarh Mo0 8126303026 Date30/4/2021 Author: Narasimma Pawar S/0 Rambabu Powerhouse, Karhala Road, Mau0 908400582 Note: I am CC 551 Sanjeev Kumar certifying that the copy of Tahrir has been recorded on the computer word and word"
28
 
29
+ Statutes:['IPC_323', 'IPC_354', 'IPC_307', 'IPC_506']
30
  -----
31
 
32
  ###
 
38
 
39
  Learn from the examples provided in the context to understand the task of charge or statute prediction.
40
  Your response should be focused on providing the exact statute or charge that aligns with the legal principles and precedents applicable to the given facts.
41
+ In your response, include only the statutes you are most confident about.Ensure that the statutes generated as responses are valid and recognized legal statutes applicable in FIRs. In certain cases you can also apply sections from special acts including but not limited to 'The_Arms_Act_27' , 'The_Motor_Vehicles_Act_1988', 'Dowry_Prohibition_Act_1961', like 'Dowry_Prohibition_Act_1961_3'. Avoid generating fabricated or invalid statutes.
 
42
  Think step by step to cover all possible statutes that are relevant to the fact statement.
43
 
44
  Fact Statement: ```{fact}```
 
103
  request = requests.post(constructed_url, params=params, headers=headers, json=body)
104
  return request.json()[0]['translations'][0]['text']
105
 
106
+
107
+
108
+
109
+
110
+ def get_random_sample():
111
+ filename = "Apr.csv" # Replace 'your_file.csv' with your actual file path
112
+ with open(filename, 'r', newline='') as csvfile:
113
+ # Step 3: Read all rows into a list
114
+ reader = csv.reader(csvfile)
115
+ rows = [row for row in reader]
116
+
117
+ # Step 4: Generate a random index
118
+ random_index = random.randint(0, len(rows) - 1)
119
+ print(ra)
120
+
121
+ # Step 5: Retrieve the row at the random index
122
+ random_row = rows[random_index]
123
+
124
+ # Step 6: Print or process the random row
125
+ return random_row
126
+
127
+ example = get_random_sample()
128
+
129
+
130
  def predict_statutes(fir_text,language):
131
  if language == 'Hindi':
132
  text = translate(fir_text)
133
  else:
134
  text = fir_text
135
+
136
+ ac_statute= example[-1] if fir_text==example[5] else ''
137
+
138
  if text:
139
  gpt_output = generate(text)
140
  statutes_list = extract_statutes(gpt_output)
141
  if statutes_list:
142
+ return ("\n".join(f"- {statute}" for statute in statutes_list),ac_statute)
143
  else:
144
+ return ("No statutes were predicted. Please check the FIR text and try again.",ac_statute)
145
  else:
146
+ return ("Please enter the FIR text to predict statutes.",ac_statute)
147
+
 
148
  demo = gr.Interface(
149
  title='Statute Prediction',
150
  description='Uses AI to analyze the FIR content and intelligently predict applicable statutes',
 
153
  gr.Dropdown(label="Select Language", choices=["English", "Hindi"], value="English"),
154
  # gr.Slider(minimum=0.1,maximum=1.0,value=0.5,step=0.1),
155
  ],
156
+ outputs=[gr.Textbox(label="Predicted Statutes"),gr.Textbox(label="Actual Statutes",value=example[-1])],
157
+ examples=[[example[5], "English"]],
158
  )
159
 
160
  demo.launch()
test.py ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import csv
2
+ import random
3
+
4
+ # Step 1: Import the necessary modules
5
+
6
+ # Step 2: Open the CSV file in read mode
7
+ filename = "Apr.csv" # Replace 'your_file.csv' with your actual file path
8
+ with open(filename, 'r', newline='') as csvfile:
9
+ # Step 3: Read all rows into a list
10
+ reader = csv.reader(csvfile)
11
+ rows = [row for row in reader]
12
+
13
+ # Step 4: Generate a random index
14
+ random_index = random.randint(0, len(rows) - 1)
15
+
16
+ # Step 5: Retrieve the row at the random index
17
+ random_row = rows[random_index]
18
+
19
+ # Step 6: Print or process the random row
20
+ print(random_row)