diff --git a/.github/workflows/compile.yml b/.github/workflows/compile.yml index c25cdd2..92f930b 100644 --- a/.github/workflows/compile.yml +++ b/.github/workflows/compile.yml @@ -33,13 +33,17 @@ jobs: - name: Prepare output directory run: | mkdir .compiled - cp README.md .compiled cp LICENSE .compiled - name: Compile run: | bash ./compile.sh .compiled .currpdfs + - name: Generate README + run: | + cp README.md .compiled/README.md + python3 ./utils/update_readme.py --src-path ./src --readme-path .compiled/README.md --gh-link https://github.com/NotXia/unibo-ai-notes/blob/pdfs + - name: Move to pdfs branch uses: s0/git-publish-subdir-action@develop diff --git a/src/cognition-and-neuroscience/metadata.json b/src/cognition-and-neuroscience/metadata.json new file mode 100644 index 0000000..d9a9632 --- /dev/null +++ b/src/cognition-and-neuroscience/metadata.json @@ -0,0 +1,11 @@ +{ + "name": "Cognition and Neuroscience", + "year": 1, + "semester": 2, + "pdfs": [ + { + "name": "Module 1", + "path": "cn.pdf" + } + ] +} \ No newline at end of file diff --git a/src/combinatorial-decision-making-and-optimization/metadata.json b/src/combinatorial-decision-making-and-optimization/metadata.json new file mode 100644 index 0000000..1b42739 --- /dev/null +++ b/src/combinatorial-decision-making-and-optimization/metadata.json @@ -0,0 +1,15 @@ +{ + "name": "Combinatorial Decision Making and Optimization", + "year": 1, + "semester": 2, + "pdfs": [ + { + "name": "Module 1", + "path": "module1/cdmo1.pdf" + }, + { + "name": "Module 2", + "path": "module2/cdmo2.pdf" + } + ] +} \ No newline at end of file diff --git a/src/deep-learning/metadata.json b/src/deep-learning/metadata.json new file mode 100644 index 0000000..37bdc24 --- /dev/null +++ b/src/deep-learning/metadata.json @@ -0,0 +1,11 @@ +{ + "name": "Deep Learning", + "year": 1, + "semester": 2, + "pdfs": [ + { + "name": null, + "path": "dl.pdf" + } + ] +} \ No newline at end of file diff --git a/src/fundamentals-of-ai-and-kr/metadata.json b/src/fundamentals-of-ai-and-kr/metadata.json new file mode 100644 index 0000000..65fda9a --- /dev/null +++ b/src/fundamentals-of-ai-and-kr/metadata.json @@ -0,0 +1,19 @@ +{ + "name": "Fundamentals of Artificial Intelligence and Knowledge Representation", + "year": 1, + "semester": 1, + "pdfs": [ + { + "name": "Module 1", + "path": "module1/faikr1.pdf" + }, + { + "name": "Module 2", + "path": "module2/faikr2.pdf" + }, + { + "name": "Module 3", + "path": "module3/faikr3.pdf" + } + ] +} \ No newline at end of file diff --git a/src/image-processing-and-computer-vision/metadata.json b/src/image-processing-and-computer-vision/metadata.json new file mode 100644 index 0000000..8924adf --- /dev/null +++ b/src/image-processing-and-computer-vision/metadata.json @@ -0,0 +1,15 @@ +{ + "name": "Image Processing and Computer Vision", + "year": 1, + "semester": 2, + "pdfs": [ + { + "name": "Module 1", + "path": "module1/ipcv1.pdf" + }, + { + "name": "Module 2", + "path": "module2/ipcv2.pdf" + } + ] +} \ No newline at end of file diff --git a/src/languages-and-algorithms-for-ai/metadata.json b/src/languages-and-algorithms-for-ai/metadata.json new file mode 100644 index 0000000..f5b4350 --- /dev/null +++ b/src/languages-and-algorithms-for-ai/metadata.json @@ -0,0 +1,15 @@ +{ + "name": "Languages and Algorithms for Artificial Intelligence", + "year": 1, + "semester": 3, + "pdfs": [ + { + "name": "Module 2", + "path": "module2/laai2.pdf" + }, + { + "name": "Module 3", + "path": "module3/laai3.pdf" + } + ] +} \ No newline at end of file diff --git a/src/machine-learning-and-data-mining/metadata.json b/src/machine-learning-and-data-mining/metadata.json new file mode 100644 index 0000000..5e929a1 --- /dev/null +++ b/src/machine-learning-and-data-mining/metadata.json @@ -0,0 +1,11 @@ +{ + "name": "Machine Learning and Data Mining", + "year": 1, + "semester": 1, + "pdfs": [ + { + "name": null, + "path": "dm-ml.pdf" + } + ] +} \ No newline at end of file diff --git a/src/statistical-and-mathematical-methods-for-ai/metadata.json b/src/statistical-and-mathematical-methods-for-ai/metadata.json new file mode 100644 index 0000000..7eb7ecf --- /dev/null +++ b/src/statistical-and-mathematical-methods-for-ai/metadata.json @@ -0,0 +1,11 @@ +{ + "name": "Statistical and Mathematical Methods for Artificial Intelligence", + "year": 1, + "semester": 1, + "pdfs": [ + { + "name": null, + "path": "smm.pdf" + } + ] +} \ No newline at end of file diff --git a/utils/update_readme.py b/utils/update_readme.py new file mode 100644 index 0000000..9a2fb97 --- /dev/null +++ b/utils/update_readme.py @@ -0,0 +1,55 @@ +import argparse +import os +import pathlib +import json + +METADATA_FILENAME = "metadata.json" + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(prog="README updater") + parser.add_argument("--src-path", type=str, required=True, help="Path to the .tex sources") + parser.add_argument("--readme-path", type=str, required=True, help="Path to the readme") + parser.add_argument("--gh-link", type=str, required=True, help="Link to the GitHub repo") + args = parser.parse_args() + + notes_metadata = {} + + # Reads courses metadata + for root, dirs, files in os.walk(args.src_path): + if METADATA_FILENAME in files: + with open(os.path.join(root, METADATA_FILENAME)) as f: + metadata = json.load(f) + dir_name = pathlib.PurePath(root).name + gh_path = os.path.join(args.gh_link, dir_name) + + if metadata["year"] not in notes_metadata: notes_metadata[metadata["year"]] = {} + if metadata["semester"] not in notes_metadata[metadata["year"]]: notes_metadata[metadata["year"]][metadata["semester"]] = {} + + notes_metadata[metadata["year"]][metadata["semester"]][metadata["name"]] = { + "name": metadata["name"], + "content": [ + { + "name": pdf["name"], + "url": os.path.join(gh_path, pdf["path"]) + } + for pdf in metadata["pdfs"] + ] + } + + # Appends links to README + with open(args.readme_path, "a") as readme_f: + for year in sorted(notes_metadata.keys()): + readme_f.write(f"\n\nYear {year}\n---\n") + + for semester in sorted(notes_metadata[year].keys()): + for course in sorted(notes_metadata[year][semester]): + course_name = notes_metadata[year][semester][course]["name"] + course_content = notes_metadata[year][semester][course]["content"] + + if (len(course_content) == 1) and (course_content[0]["name"] is None): + readme_f.write(f"- [{course_name}]({course_content[0]['url']})\n") + else: + readme_f.write(f"- {course_name}\n") + for content in course_content: + readme_f.write(f" - [{content['name']}]({content['url']})\n")