Preeti Dave commited on
Commit
9ebd77e
·
1 Parent(s): af29acd
Files changed (1) hide show
  1. app.py +79 -4
app.py CHANGED
@@ -1,7 +1,82 @@
1
  import gradio as gr
 
2
 
3
- def greet(name):
4
- return "Hello " + name + "!!"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
- demo = gr.Interface(fn=greet, inputs="text", outputs="text")
7
- demo.launch()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
+ from collections import defaultdict
3
 
4
+ # Function to detect conflicts between two cases
5
+ def detect_conflicts(case_1, case_2):
6
+ # Sample data - should be replaced with actual data fetching logic
7
+ cases_data = [
8
+ {
9
+ "id": "46690",
10
+ "title": "United Operations v. Comoros",
11
+ "parties": ["3535", "64825"]
12
+ },
13
+ {
14
+ "id": "46609",
15
+ "title": "Expropriated Religious Properties",
16
+ "parties": ["7302", "7319", "7790", "3535"] # Party "3535" added to cause a conflict
17
+ },
18
+ {
19
+ "id": "46542",
20
+ "title": "Bellwether and Tecnipetrol v. Ecuador and Petroecuador",
21
+ "parties": ["7569", "13856", "64647", "64648"]
22
+ }
23
+ ]
24
 
25
+ # A function to detect conflicts between two case inputs
26
+ conflicts = defaultdict(list)
27
+
28
+ # Convert case_1 and case_2 to IDs
29
+ case_1 = case_1.strip()
30
+ case_2 = case_2.strip()
31
+
32
+ # Find the two cases from the sample data
33
+ selected_cases = [
34
+ case for case in cases_data if case_1 == case["id"] or case_2 == case["id"]
35
+ ]
36
+
37
+ # If both cases are found, proceed to check conflicts
38
+ if len(selected_cases) == 2:
39
+ case_1_parties = set(selected_cases[0]["parties"])
40
+ case_2_parties = set(selected_cases[1]["parties"])
41
+
42
+ # Find the common parties
43
+ common_parties = case_1_parties.intersection(case_2_parties)
44
+
45
+ if common_parties:
46
+ conflicts_output = "Conflicts Detected:\n"
47
+ for party in common_parties:
48
+ conflicts_output += f"Party {party} is involved in the following cases:\n"
49
+ conflicts_output += f" - {selected_cases[0]['title']} (Case ID: {selected_cases[0]['id']})\n"
50
+ conflicts_output += f" - {selected_cases[1]['title']} (Case ID: {selected_cases[1]['id']})\n"
51
+ conflicts_output += "-" * 40 + "\n"
52
+ else:
53
+ conflicts_output = "No conflicts detected."
54
+
55
+ return conflicts_output
56
+ else:
57
+ return "Invalid Case IDs"
58
+
59
+ # Gradio UI Setup
60
+ def create_gradio_ui():
61
+ with gr.Blocks() as demo:
62
+ gr.Markdown("# Conflict Detection Tool")
63
+ gr.Markdown("This app detects conflicts between two cases based on party involvement.")
64
+
65
+ # User inputs for case IDs
66
+ case_id_1 = gr.Textbox(label="Enter Case ID 1", placeholder="Enter the first case ID here...")
67
+ case_id_2 = gr.Textbox(label="Enter Case ID 2", placeholder="Enter the second case ID here...")
68
+
69
+ # Output area for the result
70
+ output_area = gr.Textbox(label="Conflict Detection Output", lines=10)
71
+
72
+ # Button to trigger conflict detection
73
+ detect_button = gr.Button("Detect Conflicts")
74
+
75
+ # Define button click behavior
76
+ detect_button.click(detect_conflicts, inputs=[case_id_1, case_id_2], outputs=[output_area])
77
+
78
+ demo.launch()
79
+
80
+ # Run the Gradio app
81
+ if __name__ == "__main__":
82
+ create_gradio_ui()