Spaces:
Runtime error
Runtime error
Upload folder using huggingface_hub
Browse files- gradio_app.py +19 -20
gradio_app.py
CHANGED
@@ -107,24 +107,24 @@ def translate(text):
|
|
107 |
|
108 |
|
109 |
|
110 |
-
def get_random_sample():
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
|
121 |
-
|
122 |
-
|
123 |
|
124 |
-
|
125 |
-
|
126 |
|
127 |
-
example = get_random_sample()
|
128 |
|
129 |
|
130 |
def predict_statutes(fir_text,language):
|
@@ -133,17 +133,16 @@ def predict_statutes(fir_text,language):
|
|
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
|
143 |
else:
|
144 |
-
return
|
145 |
else:
|
146 |
-
return
|
147 |
|
148 |
demo = gr.Interface(
|
149 |
title='Statute Prediction',
|
@@ -153,8 +152,8 @@ demo = gr.Interface(
|
|
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")
|
157 |
-
examples=[[example[5], "English"]],
|
158 |
)
|
159 |
|
160 |
demo.launch()
|
|
|
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):
|
|
|
133 |
else:
|
134 |
text = fir_text
|
135 |
|
|
|
136 |
|
137 |
if text:
|
138 |
gpt_output = generate(text)
|
139 |
statutes_list = extract_statutes(gpt_output)
|
140 |
if statutes_list:
|
141 |
+
return "\n".join(f"- {statute}" for statute in statutes_list)
|
142 |
else:
|
143 |
+
return "No statutes were predicted. Please check the FIR text and try again."
|
144 |
else:
|
145 |
+
return "Please enter the FIR text to predict statutes."
|
146 |
|
147 |
demo = gr.Interface(
|
148 |
title='Statute Prediction',
|
|
|
152 |
gr.Dropdown(label="Select Language", choices=["English", "Hindi"], value="English"),
|
153 |
# gr.Slider(minimum=0.1,maximum=1.0,value=0.5,step=0.1),
|
154 |
],
|
155 |
+
outputs=[gr.Textbox(label="Predicted Statutes")],
|
156 |
+
# examples=[[example[5], "English"]],
|
157 |
)
|
158 |
|
159 |
demo.launch()
|