Spaces:
Sleeping
Sleeping
legaltextai
commited on
Commit
•
5763b22
1
Parent(s):
36dca75
Update app.py
Browse files
app.py
CHANGED
@@ -1,13 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
-
from bs4 import BeautifulSoup
|
3 |
import requests
|
4 |
-
import
|
5 |
-
|
6 |
-
headers = {
|
7 |
-
"User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582"
|
8 |
-
}
|
9 |
-
|
10 |
-
proxies = {"http": os.getenv("HTTP_PROXY")}
|
11 |
|
12 |
def search_legal_cases(query, num_results=10):
|
13 |
url = "https://scholar.google.com/scholar?hl=en&as_sdt=6"
|
@@ -22,7 +15,7 @@ def search_legal_cases(query, num_results=10):
|
|
22 |
"as_sdt": "4", # This parameter filters the search results to legal cases
|
23 |
}
|
24 |
|
25 |
-
response = requests.get(url,
|
26 |
soup = BeautifulSoup(response.text, "html.parser")
|
27 |
|
28 |
results = []
|
@@ -35,23 +28,15 @@ def search_legal_cases(query, num_results=10):
|
|
35 |
|
36 |
return results
|
37 |
|
38 |
-
def
|
39 |
-
results = search_legal_cases(
|
40 |
if results:
|
41 |
-
|
42 |
-
|
|
|
|
|
43 |
else:
|
44 |
return "No results found."
|
45 |
|
46 |
-
|
47 |
-
|
48 |
-
return f"Title:\n{title}\n\nCitation:\n{citation}\n\nLink:\n{link}"
|
49 |
-
|
50 |
-
iface = gr.Interface(
|
51 |
-
fn=display_results,
|
52 |
-
inputs=gr.inputs.Textbox(lines=1, placeholder="Enter case name, e.g. brown v board supreme, 372 US 335, google v oracle appeal"),
|
53 |
-
outputs=gr.outputs.Textbox(label="Results"),
|
54 |
-
live=True
|
55 |
-
)
|
56 |
-
|
57 |
-
iface.launch()
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import requests
|
3 |
+
from bs4 import BeautifulSoup
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
|
5 |
def search_legal_cases(query, num_results=10):
|
6 |
url = "https://scholar.google.com/scholar?hl=en&as_sdt=6"
|
|
|
15 |
"as_sdt": "4", # This parameter filters the search results to legal cases
|
16 |
}
|
17 |
|
18 |
+
response = requests.get(url, headers=headers, params=params)
|
19 |
soup = BeautifulSoup(response.text, "html.parser")
|
20 |
|
21 |
results = []
|
|
|
28 |
|
29 |
return results
|
30 |
|
31 |
+
def get_legal_cases(query):
|
32 |
+
results = search_legal_cases(query)
|
33 |
if results:
|
34 |
+
response = ""
|
35 |
+
for title, link, citation in results:
|
36 |
+
response += f"**Title:** {title}\n**Link:** {link}\n**Citation:** {citation}\n\n"
|
37 |
+
return response
|
38 |
else:
|
39 |
return "No results found."
|
40 |
|
41 |
+
demo = gr.Interface(fn=get_legal_cases, inputs="text", outputs="markdown")
|
42 |
+
demo.launch()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|