Johan713 commited on
Commit
1cee0b7
·
verified ·
1 Parent(s): 8a0c373

Update app2.py

Browse files
Files changed (1) hide show
  1. app2.py +1 -135
app2.py CHANGED
@@ -1252,138 +1252,6 @@ def get_trend_description(df):
1252
  else:
1253
  return "The number of cases has remained relatively stable over the five-year period."
1254
 
1255
- CITIES_BY_STATE = {
1256
- "Alabama": ["Birmingham", "Montgomery", "Mobile", "Huntsville", "Tuscaloosa", "Hoover", "Dothan", "Auburn", "Decatur", "Madison", "Florence", "Gadsden", "Vestavia Hills", "Prattville", "Phenix City", "Alabaster", "Bessemer", "Prichard", "Opelika", "Enterprise"],
1257
- "Alaska": ["Anchorage", "Fairbanks", "Juneau", "Sitka", "Ketchikan", "Wasilla", "Kenai", "Kodiak", "Bethel", "Palmer", "Homer", "Unalaska", "Barrow", "Soldotna", "Valdez", "Nome", "Kotzebue", "Seward", "Wrangell", "Dillingham"],
1258
- "Arizona": ["Phoenix", "Tucson", "Mesa", "Chandler", "Glendale", "Scottsdale", "Gilbert", "Tempe", "Peoria", "Surprise", "Yuma", "Avondale", "Goodyear", "Flagstaff", "Buckeye", "Lake Havasu City", "Casa Grande", "Sierra Vista", "Maricopa", "Oro Valley"],
1259
- "Arkansas": ["Little Rock", "Fort Smith", "Fayetteville", "Springdale", "Jonesboro", "North Little Rock", "Conway", "Rogers", "Pine Bluff", "Bentonville", "Hot Springs", "Benton", "Texarkana", "Sherwood", "Jacksonville", "Russellville", "Bella Vista", "West Memphis", "Paragould", "Cabot"],
1260
- "California": ["Los Angeles", "San Diego", "San Jose", "San Francisco", "Fresno", "Sacramento", "Long Beach", "Oakland", "Bakersfield", "Anaheim", "Santa Ana", "Riverside", "Stockton", "Irvine", "Chula Vista", "Fremont", "San Bernardino", "Modesto", "Fontana", "Oxnard"],
1261
- "Colorado": ["Denver", "Colorado Springs", "Aurora", "Fort Collins", "Lakewood", "Thornton", "Arvada", "Westminster", "Pueblo", "Centennial", "Boulder", "Greeley", "Longmont", "Loveland", "Broomfield", "Grand Junction", "Castle Rock", "Commerce City", "Parker", "Northglenn"],
1262
- "Connecticut": ["Bridgeport", "New Haven", "Stamford", "Hartford", "Waterbury", "Norwalk", "Danbury", "New Britain", "West Hartford", "Greenwich", "Hamden", "Meriden", "Bristol", "Manchester", "West Haven", "Milford", "Stratford", "East Hartford", "Middletown", "Wallingford"],
1263
- "Delaware": ["Wilmington", "Dover", "Newark", "Middletown", "Smyrna", "Milford", "Seaford", "Georgetown", "Elsmere", "New Castle", "Millsboro", "Laurel", "Harrington", "Camden", "Clayton", "Lewes", "Milton", "Selbyville", "Rehoboth Beach", "Delaware City"],
1264
- "Florida": ["Jacksonville", "Miami", "Tampa", "Orlando", "St. Petersburg", "Hialeah", "Tallahassee", "Fort Lauderdale", "Port St. Lucie", "Cape Coral", "Pembroke Pines", "Hollywood", "Miramar", "Gainesville", "Coral Springs", "Miami Gardens", "Clearwater", "Palm Bay", "Pompano Beach", "West Palm Beach"],
1265
- "Georgia": ["Atlanta", "Augusta", "Columbus", "Macon", "Savannah", "Athens", "Sandy Springs", "Roswell", "Johns Creek", "Albany", "Warner Robins", "Alpharetta", "Marietta", "Valdosta", "Smyrna", "Dunwoody", "Rome", "East Point", "Milton", "Gainesville"],
1266
- "Hawaii": ["Honolulu", "East Honolulu", "Pearl City", "Hilo", "Kailua", "Waipahu", "Kaneohe", "Mililani Town", "Kahului", "Ewa Gentry", "Kihei", "Makakilo", "Wahiawa", "Schofield Barracks", "Wailuku", "Kapolei", "Ewa Beach", "Royal Kunia", "Halawa", "Waimalu"],
1267
- "Idaho": ["Boise", "Meridian", "Nampa", "Idaho Falls", "Pocatello", "Caldwell", "Coeur d'Alene", "Twin Falls", "Lewiston", "Post Falls", "Rexburg", "Eagle", "Moscow", "Mountain Home", "Ammon", "Kuna", "Hayden", "Chubbuck", "Garden City", "Blackfoot"],
1268
- "Illinois": ["Chicago", "Aurora", "Joliet", "Naperville", "Rockford", "Elgin", "Springfield", "Peoria", "Champaign", "Waukegan", "Cicero", "Bloomington", "Arlington Heights", "Evanston", "Decatur", "Schaumburg", "Bolingbrook", "Palatine", "Skokie", "Des Plaines"],
1269
- "Indiana": ["Indianapolis", "Fort Wayne", "Evansville", "South Bend", "Carmel", "Fishers", "Bloomington", "Hammond", "Gary", "Lafayette", "Muncie", "Terre Haute", "Kokomo", "Anderson", "Noblesville", "Greenwood", "Elkhart", "Mishawaka", "Lawrence", "Jeffersonville"],
1270
- "Iowa": ["Des Moines", "Cedar Rapids", "Davenport", "Sioux City", "Iowa City", "Waterloo", "Ames", "West Des Moines", "Council Bluffs", "Dubuque", "Ankeny", "Urbandale", "Cedar Falls", "Marion", "Bettendorf", "Mason City", "Clinton", "Marshalltown", "Burlington", "Ottumwa"],
1271
- "Kansas": ["Wichita", "Overland Park", "Kansas City", "Olathe", "Topeka", "Lawrence", "Shawnee", "Manhattan", "Lenexa", "Salina", "Hutchinson", "Leavenworth", "Leawood", "Dodge City", "Garden City", "Junction City", "Emporia", "Derby", "Prairie Village", "Hays"],
1272
- "Kentucky": ["Louisville", "Lexington", "Bowling Green", "Owensboro", "Covington", "Richmond", "Georgetown", "Florence", "Hopkinsville", "Nicholasville", "Frankfort", "Henderson", "Jeffersontown", "Elizabethtown", "Independence", "Radcliff", "Ashland", "Madisonville", "Erlanger", "Winchester"],
1273
- "Louisiana": ["New Orleans", "Baton Rouge", "Shreveport", "Lafayette", "Lake Charles", "Kenner", "Bossier City", "Monroe", "Alexandria", "New Iberia", "Houma", "Slidell", "Ruston", "Hammond", "Pineville", "Zachary", "Thibodaux", "Crowley", "Baker", "Minden"],
1274
- "Maine": ["Portland", "Lewiston", "Bangor", "South Portland", "Auburn", "Biddeford", "Sanford", "Brunswick", "Augusta", "Scarborough", "Saco", "Westbrook", "Windham", "Gorham", "Waterville", "York", "Falmouth", "Kennebunk", "Orono", "Standish"],
1275
- "Maryland": ["Baltimore", "Frederick", "Rockville", "Gaithersburg", "Bowie", "Hagerstown", "Annapolis", "College Park", "Salisbury", "Laurel", "Greenbelt", "Cumberland", "Westminster", "Hyattsville", "Takoma Park", "Easton", "Elkton", "Aberdeen", "Havre de Grace", "Cambridge"],
1276
- "Massachusetts": ["Boston", "Worcester", "Springfield", "Lowell", "Cambridge", "New Bedford", "Brockton", "Quincy", "Lynn", "Fall River", "Newton", "Lawrence", "Somerville", "Framingham", "Haverhill", "Waltham", "Malden", "Brookline", "Plymouth", "Medford"],
1277
- "Michigan": ["Detroit", "Grand Rapids", "Warren", "Sterling Heights", "Ann Arbor", "Lansing", "Flint", "Dearborn", "Livonia", "Troy", "Westland", "Farmington Hills", "Kalamazoo", "Wyoming", "Southfield", "Rochester Hills", "Taylor", "St. Clair Shores", "Pontiac", "Royal Oak"],
1278
- "Minnesota": ["Minneapolis", "St. Paul", "Rochester", "Duluth", "Bloomington", "Brooklyn Park", "Plymouth", "St. Cloud", "Eagan", "Woodbury", "Maple Grove", "Eden Prairie", "Coon Rapids", "Burnsville", "Blaine", "Lakeville", "Minnetonka", "Apple Valley", "Edina", "St. Louis Park"],
1279
- "Mississippi": ["Jackson", "Gulfport", "Southaven", "Hattiesburg", "Biloxi", "Meridian", "Tupelo", "Greenville", "Olive Branch", "Horn Lake", "Clinton", "Pearl", "Madison", "Starkville", "Oxford", "Columbus", "Vicksburg", "Pascagoula", "Brandon", "Ridgeland"],
1280
- "Missouri": ["Kansas City", "St. Louis", "Springfield", "Columbia", "Independence", "Lee's Summit", "O'Fallon", "St. Joseph", "St. Charles", "St. Peters", "Blue Springs", "Florissant", "Joplin", "Chesterfield", "Jefferson City", "Cape Girardeau", "Wentzville", "Wildwood", "University City", "Ballwin"],
1281
- "Montana": ["Billings", "Missoula", "Great Falls", "Bozeman", "Butte", "Helena", "Kalispell", "Havre", "Anaconda", "Miles City", "Belgrade", "Livingston", "Laurel", "Whitefish", "Lewistown", "Sidney", "Columbia Falls", "Polson", "Hamilton", "Glendive"],
1282
- "Nebraska": ["Omaha", "Lincoln", "Bellevue", "Grand Island", "Kearney", "Fremont", "Hastings", "Norfolk", "North Platte", "Columbus", "Papillion", "La Vista", "Scottsbluff", "South Sioux City", "Beatrice", "Lexington", "Alliance", "Gering", "Blair", "York"],
1283
- "Nevada": ["Las Vegas", "Henderson", "Reno", "North Las Vegas", "Sparks", "Carson City", "Fernley", "Elko", "Mesquite", "Boulder City", "Fallon", "Winnemucca", "West Wendover", "Ely", "Yerington", "Carlin", "Lovelock", "Wells", "Caliente", "Searchlight"],
1284
- "New Hampshire": ["Manchester", "Nashua", "Concord", "Dover", "Rochester", "Keene", "Derry", "Portsmouth", "Laconia", "Lebanon", "Claremont", "Somersworth", "Londonderry", "Durham", "Hampton", "Milford", "Exeter", "Merrimack", "Salem", "Hudson"],
1285
- "New Jersey": ["Newark", "Jersey City", "Paterson", "Elizabeth", "Trenton", "Clifton", "Camden", "Passaic", "Union City", "Bayonne", "East Orange", "Vineland", "New Brunswick", "Hoboken", "Perth Amboy", "West New York", "Plainfield", "Hackensack", "Sayreville", "North Bergen"],
1286
- "New Mexico": ["Albuquerque", "Las Cruces", "Rio Rancho", "Santa Fe", "Roswell", "Farmington", "Clovis", "Hobbs", "Alamogordo", "Carlsbad", "Gallup", "Deming", "Los Lunas", "Chaparral", "Sunland Park", "Los Alamos", "Portales", "Lovington", "Silver City", "Artesia"],
1287
- "New York": ["New York City", "Buffalo", "Rochester", "Yonkers", "Syracuse", "Albany", "New Rochelle", "Mount Vernon", "Schenectady", "Utica", "White Plains", "Hempstead", "Troy", "Niagara Falls", "Binghamton", "Freeport", "Valley Stream", "Long Beach", "Rome", "North Tonawanda"],
1288
- "North Carolina": ["Charlotte", "Raleigh", "Greensboro", "Durham", "Winston-Salem", "Fayetteville", "Cary", "Wilmington", "High Point", "Greenville", "Asheville", "Concord", "Gastonia", "Jacksonville", "Chapel Hill", "Rocky Mount", "Burlington", "Wilson", "Huntersville", "Kannapolis"],
1289
- "North Dakota": ["Fargo", "Bismarck", "Grand Forks", "Minot", "West Fargo", "Williston", "Dickinson", "Mandan", "Jamestown", "Wahpeton", "Devils Lake", "Valley City", "Watford City", "Grafton", "Lincoln", "Beulah", "Rugby", "Stanley", "Horace", "Casselton"],
1290
- "Ohio": ["Columbus", "Cleveland", "Cincinnati", "Toledo", "Akron", "Dayton", "Parma", "Canton", "Youngstown", "Lorain", "Hamilton", "Springfield", "Kettering", "Elyria", "Lakewood", "Cuyahoga Falls", "Middletown", "Euclid", "Mansfield", "Newark"],
1291
- "Oklahoma": ["Oklahoma City", "Tulsa", "Norman", "Broken Arrow", "Lawton", "Edmond", "Moore", "Midwest City", "Enid", "Stillwater", "Muskogee", "Bartlesville", "Owasso", "Shawnee", "Ponca City", "Ardmore", "Duncan", "Del City", "Bixby", "Sapulpa"],
1292
- "Oregon": ["Portland", "Salem", "Eugene", "Gresham", "Hillsboro", "Beaverton", "Bend", "Medford", "Springfield", "Corvallis", "Albany", "Tigard", "Lake Oswego", "Keizer", "Grants Pass", "Oregon City", "McMinnville", "Redmond", "Tualatin", "West Linn"],
1293
- "Pennsylvania": ["Philadelphia", "Pittsburgh", "Allentown", "Erie", "Reading", "Scranton", "Bethlehem", "Lancaster", "Harrisburg", "Altoona", "York", "State College", "Wilkes-Barre", "Chester", "Williamsport", "Easton", "Lebanon", "Hazleton", "New Castle", "Johnstown"],
1294
- "Rhode Island": ["Providence", "Warwick", "Cranston", "Pawtucket", "East Providence", "Woonsocket", "Coventry", "Cumberland", "North Providence", "South Kingstown", "West Warwick", "Johnston", "North Kingstown", "Newport", "Bristol", "Westerly", "Smithfield", "Lincoln", "Central Falls", "Portsmouth"],
1295
- "South Carolina": ["Columbia", "Charleston", "North Charleston", "Mount Pleasant", "Rock Hill", "Greenville", "Summerville", "Sumter", "Hilton Head Island", "Florence", "Spartanburg", "Goose Creek", "Aiken", "Myrtle Beach", "Anderson", "Greer", "Mauldin", "Greenwood", "North Augusta", "Easley"],
1296
- "South Dakota": ["Sioux Falls", "Rapid City", "Aberdeen", "Brookings", "Watertown", "Mitchell", "Yankton", "Pierre", "Huron", "Vermillion", "Spearfish", "Brandon", "Box Elder", "Madison", "Sturgis", "Belle Fourche", "Turns", "Dell Rapids", "Mobridge", "Milbank"],
1297
- "Tennessee": ["Nashville", "Memphis", "Knoxville", "Chattanooga", "Clarksville", "Murfreesboro", "Franklin", "Jackson", "Johnson City", "Bartlett", "Hendersonville", "Kingsport", "Collierville", "Cleveland", "Smyrna", "Germantown", "Brentwood", "Columbia", "La Vergne", "Spring Hill"],
1298
- "Texas": ["Houston", "San Antonio", "Dallas", "Austin", "Fort Worth", "El Paso", "Arlington", "Corpus Christi", "Plano", "Laredo", "Lubbock", "Garland", "Irving", "Amarillo", "Grand Prairie", "McKinney", "Frisco", "Brownsville", "Pasadena", "Mesquite"],
1299
- "Utah": ["Salt Lake City", "West Valley City", "Provo", "West Jordan", "Orem", "Sandy", "Ogden", "St. George", "Layton", "Taylorsville", "South Jordan", "Lehi", "Logan", "Murray", "Draper", "Bountiful", "Riverton", "Roy", "Spanish Fork", "Pleasant Grove"],
1300
- "Vermont": ["Burlington", "South Burlington", "Rutland", "Essex Junction", "Bennington", "Brattleboro", "Colchester", "Hartford", "Milton", "Barre", "Winooski", "St. Albans", "Montpelier", "Middlebury", "St. Johnsbury", "Swanton", "Springfield", "Morristown", "Williston", "Newport"],
1301
- "Virginia": ["Virginia Beach", "Norfolk", "Chesapeake", "Richmond", "Newport News", "Alexandria", "Hampton", "Roanoke", "Portsmouth", "Suffolk", "Lynchburg", "Harrisonburg", "Leesburg", "Charlottesville", "Danville", "Blacksburg", "Manassas", "Petersburg", "Winchester", "Salem"],
1302
- "Washington": ["Seattle", "Spokane", "Tacoma", "Vancouver", "Bellevue", "Kent", "Everett", "Renton", "Yakima", "Federal Way", "Spokane Valley", "Bellingham", "Kennewick", "Auburn", "Pasco", "Marysville", "Lakewood", "Redmond", "Shoreline", "Richland"],
1303
- "West Virginia": ["Charleston", "Huntington", "Morgantown", "Parkersburg", "Wheeling", "Weirton", "Fairmont", "Martinsburg", "Beckley", "Clarksburg", "South Charleston", "St. Albans", "Vienna", "Bluefield", "Dunbar", "Elkins", "Bridgeport", "Nitro", "Hurricane", "Buckhannon"],
1304
- "Wisconsin": ["Milwaukee", "Madison", "Green Bay", "Kenosha", "Racine", "Appleton", "Waukesha", "Oshkosh", "Eau Claire", "Janesville", "West Allis", "La Crosse", "Sheboygan", "Wauwatosa", "Fond du Lac", "New Berlin", "Wausau", "Brookfield", "Beloit", "Greenfield"],
1305
- "Wyoming": ["Cheyenne", "Casper", "Laramie", "Gillette", "Rock Springs", "Sheridan", "Green River", "Evanston", "Riverton", "Jackson", "Cody", "Rawlins", "Lander", "Torrington", "Powell", "Douglas", "Worland", "Buffalo", "Wheatland", "Newcastle"],
1306
- "Washington, DC": ["Washington"]
1307
- }
1308
-
1309
- def format_url_component(s):
1310
- return s.lower().replace(' ', '-').replace(',', '').replace('&', 'and')
1311
-
1312
- def search_lawyers(practice_area, state, city):
1313
- base_url = "https://www.avvo.com/search/lawyer_search"
1314
- params = {
1315
- 'q': practice_area,
1316
- 'loc': f"{city}, {state}"
1317
- }
1318
-
1319
- headers = {
1320
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
1321
- 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
1322
- 'Accept-Language': 'en-US,en;q=0.5',
1323
- 'Referer': 'https://www.avvo.com/',
1324
- 'DNT': '1',
1325
- 'Connection': 'keep-alive',
1326
- 'Upgrade-Insecure-Requests': '1',
1327
- }
1328
-
1329
- try:
1330
- response = requests.get(base_url, params=params, headers=headers)
1331
- response.raise_for_status()
1332
- soup = BeautifulSoup(response.content, 'html.parser')
1333
-
1334
- lawyer_cards = soup.find_all('div', class_='lawyer-search-result')
1335
-
1336
- lawyers = []
1337
- for card in lawyer_cards[:5]: # Limit to top 5 results
1338
- name_elem = card.find('h3', class_='v-lawyer-card-name')
1339
- if name_elem:
1340
- name = name_elem.text.strip()
1341
- location = card.find('div', class_='v-lawyer-card-location').text.strip()
1342
- practice_areas = card.find('div', class_='v-lawyer-card-practice-areas').text.strip()
1343
- profile_url = "https://www.avvo.com" + name_elem.find('a')['href']
1344
-
1345
- lawyers.append({
1346
- 'name': name,
1347
- 'location': location,
1348
- 'practice_areas': practice_areas,
1349
- 'profile_url': profile_url
1350
- })
1351
-
1352
- return lawyers
1353
- except requests.RequestException as e:
1354
- st.error(f"Error fetching lawyer data: {e}")
1355
- return []
1356
-
1357
- def lawyer_finder_ui():
1358
- st.title("Lawyer Search System")
1359
-
1360
- practice_areas = [
1361
- "Bankruptcy", "Business Law", "Civil Rights", "Criminal Defense",
1362
- "Employment Law", "Estate Planning", "Family Law", "Immigration",
1363
- "Intellectual Property", "Personal Injury", "Real Estate Law", "Tax Law"
1364
- ]
1365
-
1366
- states = list(CITIES_BY_STATE.keys())
1367
-
1368
- selected_practice_area = st.selectbox("Select a Practice Area:", practice_areas)
1369
- selected_state = st.selectbox("Select a State:", states)
1370
-
1371
- cities = CITIES_BY_STATE[selected_state]
1372
- selected_city = st.selectbox("Select a City:", cities)
1373
-
1374
- if st.button("Search Lawyers"):
1375
- with st.spinner("Searching for lawyers..."):
1376
- results = search_lawyers(selected_practice_area, selected_state, selected_city)
1377
-
1378
- if results:
1379
- st.success(f"Found {len(results)} lawyers matching your criteria.")
1380
- for lawyer in results:
1381
- with st.expander(f"{lawyer['name']} - {lawyer['location']}"):
1382
- st.write(f"**Practice Areas:** {lawyer['practice_areas']}")
1383
- st.markdown(f"[View Profile]({lawyer['profile_url']})")
1384
- else:
1385
- st.warning("No lawyers found matching your criteria. Try broadening your search.")
1386
-
1387
 
1388
  class LegalDataRetriever:
1389
  def __init__(self):
@@ -1740,7 +1608,7 @@ with st.sidebar:
1740
 
1741
  feature = st.selectbox(
1742
  "Select a feature",
1743
- ["Legal Chatbot", "Document Analysis", "Case Precedent Finder", "Legal Cost Estimator", "Contract Analysis", "Case Trend Visualizer", "Case Information Retrieval", "Automated Legal Brief Generation", "Find a Lawyer"]
1744
  )
1745
  if feature == "Legal Chatbot":
1746
  st.subheader("Legal Chatbot")
@@ -1902,8 +1770,6 @@ elif feature == "Case Information Retrieval":
1902
  elif feature == "Automated Legal Brief Generation":
1903
  automated_legal_brief_generation_ui()
1904
 
1905
- elif feature == "Find a Lawyer":
1906
- lawyer_finder_ui()
1907
  st.markdown("---")
1908
  st.markdown(
1909
  """
 
1252
  else:
1253
  return "The number of cases has remained relatively stable over the five-year period."
1254
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1255
 
1256
  class LegalDataRetriever:
1257
  def __init__(self):
 
1608
 
1609
  feature = st.selectbox(
1610
  "Select a feature",
1611
+ ["Legal Chatbot", "Document Analysis", "Case Precedent Finder", "Legal Cost Estimator", "Contract Analysis", "Case Trend Visualizer", "Case Information Retrieval", "Automated Legal Brief Generation"]
1612
  )
1613
  if feature == "Legal Chatbot":
1614
  st.subheader("Legal Chatbot")
 
1770
  elif feature == "Automated Legal Brief Generation":
1771
  automated_legal_brief_generation_ui()
1772
 
 
 
1773
  st.markdown("---")
1774
  st.markdown(
1775
  """