Skip to content

Commit

Permalink
Merge pull request #44 from inception-project/bug-40-project-without-…
Browse files Browse the repository at this point in the history
…description

Bug 40 project without description
  • Loading branch information
serwarde authored Jun 10, 2024
2 parents a54521b + eb9c36b commit 257f969
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions inception_reports/generate_reports_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,6 @@ def translate_tag(tag, translation_path=None):


def read_dir(dir_path: str, selected_projects: list = None) -> list[dict]:
"""
Reads a directory containing zip files, extracts the contents, and retrieves project metadata and annotations.
Parameters:
dir_path (str): The path to the directory containing the zip files.
Returns:
list[dict]: A list of dictionaries, where each dictionary represents a project and contains the following keys:
- "name": The name of the zip file.
- "tags": A list of tags extracted from the project metadata.
- "documents": A list of source documents from the project metadata.
- "annotations": A dictionary mapping annotation subfolder names to their corresponding CAS objects.
"""
projects = []

for file_name in os.listdir(dir_path):
Expand All @@ -191,15 +178,18 @@ def read_dir(dir_path: str, selected_projects: list = None) -> list[dict]:
if os.path.exists(project_meta_path):
with open(project_meta_path, "r") as project_meta_file:
project_meta = json.load(project_meta_file)
description = project_meta.get("description", "")
project_tags = [
translate_tag(word.strip("#"))
for word in project_meta["description"].split()
for word in description.split()
if word.startswith("#")
]
project_documents = project_meta["source_documents"]
] if description else []

project_documents = project_meta.get("source_documents")
if not project_documents:
raise ValueError("No source documents found in the project.")

annotations = {}
# Find annotation folders
annotation_folders = [
name
for name in zip_file.namelist()
Expand Down Expand Up @@ -261,14 +251,14 @@ def select_method_to_import_data():
"""

method = st.sidebar.radio(
"Choose your method to import data:", ("Manually", "API"), index=1
"Choose your method to import data:", ("Manually", "API"), index=0
)

if method == "Manually":
st.sidebar.write(
"Please input the path to the folder containing the INCEpTION projects."
)
projects_folder = st.sidebar.text_input("Projects Folder:", value="")
projects_folder = st.sidebar.text_input("Projects Folder:", value="data/gemtex_demo_projects")
button = st.sidebar.button("Generate Reports")
if button:
st.session_state["method"] = "Manually"
Expand Down

0 comments on commit 257f969

Please sign in to comment.