awacke1 commited on
Commit
18779cf
Β·
verified Β·
1 Parent(s): b3c643c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -5
app.py CHANGED
@@ -7,25 +7,32 @@ def create_search_url_wikipedia(search_query):
7
  base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
8
  return base_url + search_query.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and')
9
 
10
- # Function to scan for XML files and generate Wikipedia links for organizations
11
  def scan_for_xml_files_and_generate_links():
12
  xml_files = [f for f in os.listdir('.') if f.endswith('.xml')]
 
 
 
 
 
 
13
  for xml_file in xml_files:
14
  tree = ET.parse(xml_file)
15
  root = tree.getroot()
16
- # Assuming the XML structure provided is consistent across files
17
  for org in root.findall(".//nc:Organization", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}):
18
  short_name = org.find("nc:OrganizationAbbreviationText", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
19
  long_name = org.find("nc:OrganizationName", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
20
- st.markdown(f"- **{short_name}**: [Wikipedia]({create_search_url_wikipedia(short_name)})")
21
- st.markdown(f"- **{long_name}**: [Wikipedia]({create_search_url_wikipedia(long_name)})")
 
 
 
22
 
23
  # Streamlit UI
24
  def app():
25
  st.title("Freedom of Information Act (FOIA) Open Data πŸŒπŸ“Š")
26
  st.write("""
27
  The Freedom of Information Act (FOIA) empowers individuals by granting access to previously unreleased information and documents controlled by the United States government. Championing transparency and accountability, FOIA serves as a foundation for democratic engagement and open government initiatives. πŸŽ‰βœ¨
28
-
29
  Below is a list of datasets available under FOIA, alongside guessed Wikipedia URLs for more information. πŸ“šπŸ”
30
  """)
31
 
 
7
  base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
8
  return base_url + search_query.replace(' ', '+').replace('–', '%E2%80%93').replace('&', 'and')
9
 
10
+ # Function to scan for XML files and generate links in a markdown table
11
  def scan_for_xml_files_and_generate_links():
12
  xml_files = [f for f in os.listdir('.') if f.endswith('.xml')]
13
+ if not xml_files: # Check if the list is empty
14
+ st.markdown("No XML files found in the directory.")
15
+ return
16
+
17
+ # Start of the markdown table
18
+ markdown_table = "Filename | Abbreviation | Full Name | Links\n--- | --- | --- | ---\n"
19
  for xml_file in xml_files:
20
  tree = ET.parse(xml_file)
21
  root = tree.getroot()
 
22
  for org in root.findall(".//nc:Organization", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}):
23
  short_name = org.find("nc:OrganizationAbbreviationText", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
24
  long_name = org.find("nc:OrganizationName", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text
25
+ links = f"[Abbreviation Wikipedia]({create_search_url_wikipedia(short_name)}) | [Full Name Wikipedia]({create_search_url_wikipedia(long_name)})"
26
+ markdown_table += f"{xml_file} | {short_name} | {long_name} | {links}\n"
27
+
28
+ # Display the markdown table
29
+ st.markdown(markdown_table)
30
 
31
  # Streamlit UI
32
  def app():
33
  st.title("Freedom of Information Act (FOIA) Open Data πŸŒπŸ“Š")
34
  st.write("""
35
  The Freedom of Information Act (FOIA) empowers individuals by granting access to previously unreleased information and documents controlled by the United States government. Championing transparency and accountability, FOIA serves as a foundation for democratic engagement and open government initiatives. πŸŽ‰βœ¨
 
36
  Below is a list of datasets available under FOIA, alongside guessed Wikipedia URLs for more information. πŸ“šπŸ”
37
  """)
38