File size: 2,582 Bytes
76df5b3
 
24eca53
76df5b3
24eca53
 
76df5b3
24eca53
76df5b3
24eca53
 
 
 
 
 
 
 
 
 
 
 
76df5b3
24eca53
 
 
 
 
 
 
76df5b3
24eca53
 
76df5b3
 
 
 
24eca53
 
 
76df5b3
24eca53
76df5b3
24eca53
 
 
76df5b3
24eca53
 
 
 
76df5b3
 
24eca53
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import streamlit as st
import os
import xml.etree.ElementTree as ET

# Function to create search URL on Wikipedia
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')

# Function to scan for XML files and generate Wikipedia links for organizations
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()
        # Assuming the XML structure provided is consistent across files
        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)})")

# Streamlit UI
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. πŸ“šπŸ”
    """)

    # Example datasets under FOIA
    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",
    ]

    # Displaying the datasets table
    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()