Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,65 +1,53 @@
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
-
import
|
4 |
-
from xml.etree import ElementTree
|
5 |
|
6 |
-
# Function to create
|
7 |
-
def create_search_url_wikipedia(
|
8 |
base_url = "https://www.wikipedia.org/search-redirect.php?family=wikipedia&language=en&search="
|
9 |
-
return base_url +
|
10 |
|
11 |
-
# Function to scan
|
12 |
-
def
|
13 |
-
|
14 |
-
for
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
st.error(f"Error parsing {file}")
|
24 |
-
return urls
|
25 |
|
26 |
-
#
|
27 |
-
def
|
28 |
-
st.title("Freedom of Information Act (FOIA)
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
""")
|
34 |
-
|
35 |
-
#
|
36 |
datasets = [
|
37 |
"Provider Taxonomy",
|
38 |
"Consumer Complaint Database",
|
39 |
-
"National Bridge Inventory",
|
40 |
"Medicare Provider Utilization and Payment Data",
|
41 |
-
"
|
|
|
|
|
42 |
"Toxic Release Inventory",
|
43 |
-
"
|
44 |
-
"Public Access to Court Electronic Records (PACER)"
|
45 |
]
|
46 |
-
|
47 |
-
|
48 |
-
st.markdown("
|
49 |
-
st.markdown("| ------- | ------------- |")
|
50 |
for dataset in datasets:
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
st.markdown("## Detected URLs in Local XML Files ππ")
|
56 |
-
urls = scan_xml_for_urls()
|
57 |
-
if urls:
|
58 |
-
for url in urls:
|
59 |
-
st.markdown(f"- [URL]({url})")
|
60 |
-
else:
|
61 |
-
st.markdown("No XML files with URLs found in the current directory.")
|
62 |
|
63 |
-
# Run the main application
|
64 |
if __name__ == "__main__":
|
65 |
-
|
|
|
1 |
import streamlit as st
|
2 |
import os
|
3 |
+
import xml.etree.ElementTree as ET
|
|
|
4 |
|
5 |
+
# Function to create search URL on Wikipedia
|
6 |
+
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 |
+
|
32 |
+
# Example datasets under FOIA
|
33 |
datasets = [
|
34 |
"Provider Taxonomy",
|
35 |
"Consumer Complaint Database",
|
|
|
36 |
"Medicare Provider Utilization and Payment Data",
|
37 |
+
"Global Terrorism Database",
|
38 |
+
"National Nutrient Database",
|
39 |
+
"Patent Grant Full Text Data",
|
40 |
"Toxic Release Inventory",
|
41 |
+
"Residential Energy Consumption Survey",
|
|
|
42 |
]
|
43 |
+
|
44 |
+
# Displaying the datasets table
|
45 |
+
st.markdown("### FOIA Datasets and Wikipedia URLs")
|
|
|
46 |
for dataset in datasets:
|
47 |
+
st.markdown(f"- **{dataset}**: [Wikipedia]({create_search_url_wikipedia(dataset)})")
|
48 |
+
|
49 |
+
st.markdown("### Organizations in Found XML Files")
|
50 |
+
scan_for_xml_files_and_generate_links()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
|
|
|
52 |
if __name__ == "__main__":
|
53 |
+
app()
|