nniehaus commited on
Commit
43952b4
·
verified ·
1 Parent(s): 4e09dc8

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -9
app.py CHANGED
@@ -58,21 +58,20 @@ if st.session_state["reply"]:
58
  st.markdown("<h2 style='text-align: center; color: black;'>Recommended Neighborhoods ⬇️</h2>", unsafe_allow_html=True)
59
  st.write(st.session_state["reply"])
60
 
61
- # Extract neighborhood, city, and state information accurately
62
  neighborhoods = []
63
  for line in st.session_state["reply"].splitlines():
64
- # Only capture lines that start with a neighborhood and contain a comma
65
- if line and "," in line:
66
- location = line.split("-")[0].strip() # Capture everything before the description
 
 
67
  neighborhoods.append(location)
68
 
69
- # Debugging step: Check if neighborhoods list is populated
70
- st.write("Extracted Neighborhoods:", neighborhoods)
71
-
72
- # Display Zillow links, ensuring neighborhood and city are included in each URL
73
  st.markdown("### Zillow Search Links")
74
  for location in neighborhoods:
75
- # Ensure format "Neighborhood, City, State" for the search query
76
  full_location_query = urllib.parse.quote(location)
77
  zillow_url = f"https://www.zillow.com/homes/{full_location_query}_rb/"
78
 
 
58
  st.markdown("<h2 style='text-align: center; color: black;'>Recommended Neighborhoods ⬇️</h2>", unsafe_allow_html=True)
59
  st.write(st.session_state["reply"])
60
 
61
+ # Extract only lines with the format "Neighborhood, City, State:"
62
  neighborhoods = []
63
  for line in st.session_state["reply"].splitlines():
64
+ if line and "," in line and ":" in line: # Ensure it matches "Neighborhood, City, State:"
65
+ location = line.split(":")[0].strip() # Capture up to the first colon
66
+ # Remove any numbering
67
+ if location[0].isdigit():
68
+ location = location.split(" ", 1)[1].strip()
69
  neighborhoods.append(location)
70
 
71
+ # Display Zillow links
 
 
 
72
  st.markdown("### Zillow Search Links")
73
  for location in neighborhoods:
74
+ # Format the search query correctly
75
  full_location_query = urllib.parse.quote(location)
76
  zillow_url = f"https://www.zillow.com/homes/{full_location_query}_rb/"
77