raminass commited on
Commit
926ab2a
1 Parent(s): fb7fb6c

Upload folder using huggingface_hub

Browse files
app.py CHANGED
@@ -8,7 +8,8 @@ all = load_dataset("raminass/full_opinions_1994_2020")
8
  df = pd.DataFrame(all["train"])
9
  choices = []
10
  for index, row in df[df.category == "per_curiam"].iterrows():
11
- choices.append((f"""{row["case_name"]}""", [row["text"], row["year_filed"]]))
 
12
 
13
  max_textboxes = 100
14
 
@@ -37,16 +38,18 @@ def greet(opinion, year):
37
 
38
 
39
  def set_input(drop):
40
- return drop[0], drop[1]
41
 
42
 
43
  with gr.Blocks() as demo:
44
  with gr.Row():
45
  with gr.Column():
46
  opinion = gr.Textbox(label="Opinion")
47
- year = gr.Slider(1994, 2020, label="Year")
48
  drop = gr.Dropdown(choices=sorted(choices))
49
- greet_btn = gr.Button("Predict")
 
 
50
  op_level = gr.outputs.Label(num_top_classes=13, label="Overall")
51
 
52
  textboxes = []
@@ -59,7 +62,7 @@ with gr.Blocks() as demo:
59
  textboxes.append(t)
60
  textboxes.append(par_level)
61
 
62
- drop.select(set_input, inputs=drop, outputs=[opinion, year])
63
 
64
  greet_btn.click(
65
  fn=greet,
@@ -67,6 +70,12 @@ with gr.Blocks() as demo:
67
  outputs=[op_level] + textboxes,
68
  )
69
 
 
 
 
 
 
 
70
 
71
  if __name__ == "__main__":
72
  demo.launch()
 
8
  df = pd.DataFrame(all["train"])
9
  choices = []
10
  for index, row in df[df.category == "per_curiam"].iterrows():
11
+ if len(row["text"]) > 1000:
12
+ choices.append((f"""{row["case_name"]}""", [row["text"], row["year_filed"]]))
13
 
14
  max_textboxes = 100
15
 
 
38
 
39
 
40
  def set_input(drop):
41
+ return drop[0], drop[1], gr.Slider(visible=False)
42
 
43
 
44
  with gr.Blocks() as demo:
45
  with gr.Row():
46
  with gr.Column():
47
  opinion = gr.Textbox(label="Opinion")
48
+ year = gr.Slider(1994, 2020, step=1, label="Year")
49
  drop = gr.Dropdown(choices=sorted(choices))
50
+ with gr.Row():
51
+ clear_btn = gr.Button("Clear")
52
+ greet_btn = gr.Button("Predict")
53
  op_level = gr.outputs.Label(num_top_classes=13, label="Overall")
54
 
55
  textboxes = []
 
62
  textboxes.append(t)
63
  textboxes.append(par_level)
64
 
65
+ drop.select(set_input, inputs=drop, outputs=[opinion, year, year])
66
 
67
  greet_btn.click(
68
  fn=greet,
 
70
  outputs=[op_level] + textboxes,
71
  )
72
 
73
+ clear_btn.click(
74
+ fn=lambda: [None, 1994, gr.Slider(visible=True), None, None]
75
+ + [gr.Textbox(visible=False), gr.Label(visible=False)] * max_textboxes,
76
+ outputs=[opinion, year, year, drop, op_level] + textboxes,
77
+ )
78
+
79
 
80
  if __name__ == "__main__":
81
  demo.launch()
utils/__pycache__/__init__.cpython-310.pyc CHANGED
Binary files a/utils/__pycache__/__init__.cpython-310.pyc and b/utils/__pycache__/__init__.cpython-310.pyc differ