|
import streamlit as st |
|
import os |
|
import xml.etree.ElementTree as ET |
|
|
|
|
|
def create_search_url_wikipedia(search_query): |
|
base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search=" |
|
return base_url + search_query.replace(' ', '+').replace('β', '%E2%80%93').replace('&', 'and') |
|
|
|
|
|
def scan_for_xml_files_and_generate_links(): |
|
xml_files = [f for f in os.listdir('.') if f.endswith('.xml')] |
|
for xml_file in xml_files: |
|
tree = ET.parse(xml_file) |
|
root = tree.getroot() |
|
|
|
for org in root.findall(".//nc:Organization", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}): |
|
short_name = org.find("nc:OrganizationAbbreviationText", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text |
|
long_name = org.find("nc:OrganizationName", namespaces={'nc': 'http://niem.gov/niem/niem-core/2.0'}).text |
|
st.markdown(f"- **{short_name}**: [Wikipedia]({create_search_url_wikipedia(short_name)})") |
|
st.markdown(f"- **{long_name}**: [Wikipedia]({create_search_url_wikipedia(long_name)})") |
|
|
|
|
|
def app(): |
|
st.title("Freedom of Information Act (FOIA) Open Data ππ") |
|
st.write(""" |
|
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. πβ¨ |
|
|
|
Below is a list of datasets available under FOIA, alongside guessed Wikipedia URLs for more information. ππ |
|
""") |
|
|
|
|
|
datasets = [ |
|
"Provider Taxonomy", |
|
"Consumer Complaint Database", |
|
"Medicare Provider Utilization and Payment Data", |
|
"Global Terrorism Database", |
|
"National Nutrient Database", |
|
"Patent Grant Full Text Data", |
|
"Toxic Release Inventory", |
|
"Residential Energy Consumption Survey", |
|
] |
|
|
|
|
|
st.markdown("### FOIA Datasets and Wikipedia URLs") |
|
for dataset in datasets: |
|
st.markdown(f"- **{dataset}**: [Wikipedia]({create_search_url_wikipedia(dataset)})") |
|
|
|
st.markdown("### Organizations in Found XML Files") |
|
scan_for_xml_files_and_generate_links() |
|
|
|
if __name__ == "__main__": |
|
app() |
|
|