diff --git a/.github/workflows/merge-contexts-metadata.yaml b/.github/workflows/merge-contexts-metadata.yaml new file mode 100644 index 0000000..11be994 --- /dev/null +++ b/.github/workflows/merge-contexts-metadata.yaml @@ -0,0 +1,34 @@ +name: Merge YAML Files + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + merge-yaml: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.11' + + - name: Install dependencies + run: pip install pyyaml + + - name: Run YAML merge script + run: python scripts/merge_contexts_metadata.py + + - name: Commit and push merged YAML file + run: | + git config --local user.email "action@github.com" + git config --local user.name "GitHub Action" + git add merged-contexts-metadata.yaml + git diff --quiet && git diff --staged --quiet || git commit -m "Update contexts metadata file" + git push diff --git a/CITATION.cff b/CITATION.cff index 75fc89e..9596a2c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -16,11 +16,15 @@ authors: - given-names: Anna family-names: Schwerdtel affiliation: Humboldt-Universität zu Berlin + - given-names: Tobias + family-names: Hille + affiliation: University of Kassel + orcid: 'https://orcid.org/0000-0001-7813-9799' repository-code: 'https://github.com/fcatools/contexts' abstract: >- - This repository contains a collection of formal contexts to pursue - Formal Concept Analysis. The metadata for the contexts is contained - in the file contexts.yaml. + This repository contains a collection of formal contexts + to pursue Formal Concept Analysis. The metadata for the + contexts is contained in the file contexts.yaml. license: CC0-1.0 commit: 6adc703bcb89c5b97709ac7a60930e9c962cc0c2 date-released: '2024-04-11' diff --git a/README.md b/README.md index 9084a4d..76d81bf 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This repository contains a collection of formal contexts to pursue The metadata for [the contexts](https://github.com/fcatools/contexts/tree/main/contexts) is -contained in [this YAML file](contexts.yaml). +contained in [this YAML file](merged-contexts-metadata.yaml). More contexts can be found in the repository for [ConExp-CLJ](https://github.com/tomhanika/conexp-clj/tree/dev/testing-data), @@ -24,7 +24,7 @@ example, in Python 3 you could do: ```python import urllib.request -url = "https://github.com/fcatools/contexts/raw/main/contexts/livingbeings_en.cxt" +url = "https://github.com/fcatools/contexts/raw/main/contexts/living-beings-and-water/livingbeings_en.cxt" context = urllib.request.urlopen(url).read().decode("utf-8") ``` @@ -42,16 +42,18 @@ If you think your context is suitable, then proceed as follows: 1. [Fork this repository](https://github.com/fcatools/contexts/fork) and make the following changes in your fork: - 1. Add your ASCII-encoded CXT file to the - [contexts](https://github.com/fcatools/contexts/tree/main/contexts) - directory, using a meaningful name (English, all lowercase, with - two letters indicating the [ISO 639 language - code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) + 1. Add a subfolder to the [contexts](https://github.com/fcatools/contexts/tree/main/contexts) + directory, and add your ASCII-encoded CXT file there. + Use a meaningful name for both (English, all lowercase, with + two letters indicating the [ISO 639 language code](https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes) at the end, e.g., `bodiesofwater_de.cxt` for the German bodies of water context). - 2. Describe your context in [contexts.yaml](contexts.yaml) + 2. Describe your context in a metadata yaml file following the example of the other contexts. Try to be concise and precise. + 3. Optionally: Merge the metadata automatically by running the included python script + ([scripts/merge_contexts_metadata.py](scripts/merge_contexts_metadata.py), + requires ```pyyaml```). 2. Make a pull request to merge your changes into this repository. ## Further information diff --git a/contexts.yaml b/contexts.yaml deleted file mode 100644 index b3df020..0000000 --- a/contexts.yaml +++ /dev/null @@ -1,159 +0,0 @@ ---- -animals_en.cxt: - title: Animals - source: "Ganter, B., Wille, R., & Stumme, G. (2005). Formal Concept Analysis: Foundations and Applications (Vol. 3626). Springer, p. 27" - size: - objects: 35 - attributes: 11 - language: English - description: animals and their characteristics - -bodiesofwater_en.cxt: - title: Bodies of water - source: "Wille, R. (1984). Liniendiagramme hierarchischer Begriffssysteme. Studien zur Klassifikation. Indeks Verlag" - size: - objects: 8 - attributes: 6 - language: English - description: bodies of water and their properties - -bodiesofwater_de.cxt: - title: Gewässer - source: "Wille, R. (1984). Liniendiagramme hierarchischer Begriffssysteme. Studien zur Klassifikation. Indeks Verlag" - size: - objects: 8 - attributes: 6 - language: German - description: bodies of water and their properties - note: German version of bodiesofwater_en.cxt - -driveconcepts_en.cxt: - title: Drive Concepts - source: "Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 39" - size: - objects: 5 - attributes: 25 - language: English - description: drive concepts for motorcars - note: "Derived from a table on page 402 in the book Schlag nach! 100000 Tatsachen aus allen Wissensgebieten. 13. Auflage. Meyers Lexikonverlag, 1988" - -driveconcepts_de.cxt: - title: Drive Concepts - source: "Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 39" - size: - objects: 5 - attributes: 25 - language: German - description: drive concepts for motorcars - note: German version of driveconcepts_en.cxt - -famous_animals_en.cxt: - title: Famous Animals - source: "Priss, U. (2006), Formal concept analysis in information science. Ann. Rev. Info. Sci. Tech., 40: 521-543. p.525" - size: - objects: 5 - attributes: 6 - language: English - description: famous animals and their characteristics - -livingbeings_en.cxt: - title: Living Beings and Water - source: "Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 18" - size: - objects: 8 - attributes: 9 - language: English - description: conditions different living beings need - -livingbeings_de.cxt: - title: Lebewesen und Wasser - source: "Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 18" - size: - objects: 8 - attributes: 9 - language: German - description: conditions different living beings need - note: German version of livingbeings_en.cxt - -missmarple_en.cxt: - title: Methods of murder in Miss Marple novels - source: "Schott, B. (2004). Schotts Sammelsurium. Bloomsbury, Berlin" - size: - objects: 12 - attributes: 6 - language: English - description: methods of murder in Miss Marple novels (not short stories!) - -missmarple_de.cxt: - title: Mordmethoden in Miss-Marple-Romanen - source: "Schott, B. (2004). Schotts Sammelsurium. Bloomsbury, Berlin" - size: - objects: 12 - attributes: 6 - language: German / English - description: methods of murder in Miss Marple novels (not short stories!) - note: German version of missmarple_en.cxt - -music_en.cxt: - title: Music - source: "Ganter, B., Wille, R., & Stumme, G. (2005). Formal Concept Analysis: Foundations and Applications (Vol. 3626). Springer, p. 22" - size: - objects: 31 - attributes: 11 - language: English - description: music and their characteristics - -newzealand_en.cxt: - title: New Zealand Leasure - source: "DK Eyewitness Travel Guide New Zealand. Dorling Kindersley Publishing Inc. 2001." - size: - objects: 13 - attributes: 8 - language: English - description: Places in New Zealand and offered activities - -officesupplies_en.cxt: - title: Office Supplies - source: "Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 25" - size: - objects: 8 - attributes: 5 - language: English - description: service offers of an office supplies business - -officesupplies_de.cxt: - title: Bürobedarf - source: "Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 25" - size: - objects: 8 - attributes: 5 - language: German - description: service offers of an office supplies business - note: German version of officesupplies_en.cxt - -planets_en.cxt: - title: Planets - source: "Anggraini, D. (2011). Analisis Perubahan Kelompok Berdasarkan Perubahan Nilai Jual Pada Bloomberg Market Data dengan Menggunakan Formal Concept Analysis, p. 7" - size: - objects: 9 - attributes: 7 - language: English - description: size and distance of planets - -seasoningplanner_de.cxt: - title: Gewürzplaner - source: "Mahn, M. (2014). Gewürze: Das Standardwerk. Christian Verlag GmbH, München" - size: - objects: 56 - attributes: 37 - language: German - description: spices and herbs together and the meals they match - -tealady.cxt: - title: Tea Ladies - source: "Wille, R. (1992). Concept Lattices and Conceptual Knowledge Systems. Computers & Mathematics with Applications, 23, 6-9, p. 493-515" - size: - objects: 18 - attributes: 14 - language: - description: participation of social events by some ladies in Old City diff --git a/contexts/animals_en.cxt b/contexts/animals/animals_en.cxt similarity index 100% rename from contexts/animals_en.cxt rename to contexts/animals/animals_en.cxt diff --git a/contexts/animals/metadata.yaml b/contexts/animals/metadata.yaml new file mode 100644 index 0000000..bdd5d97 --- /dev/null +++ b/contexts/animals/metadata.yaml @@ -0,0 +1,8 @@ +animals/animals_en.cxt: + title: Animals + source: "Ganter, B., Wille, R., & Stumme, G. (2005). Formal Concept Analysis: Foundations and Applications (Vol. 3626). Springer, p. 27" + size: + objects: 35 + attributes: 11 + language: English + description: animals and their characteristics diff --git a/contexts/bodiesofwater_de.cxt b/contexts/bodies-of-water/bodiesofwater_de.cxt similarity index 100% rename from contexts/bodiesofwater_de.cxt rename to contexts/bodies-of-water/bodiesofwater_de.cxt diff --git a/contexts/bodiesofwater_en.cxt b/contexts/bodies-of-water/bodiesofwater_en.cxt similarity index 100% rename from contexts/bodiesofwater_en.cxt rename to contexts/bodies-of-water/bodiesofwater_en.cxt diff --git a/contexts/bodies-of-water/metadata.yaml b/contexts/bodies-of-water/metadata.yaml new file mode 100644 index 0000000..5122b95 --- /dev/null +++ b/contexts/bodies-of-water/metadata.yaml @@ -0,0 +1,18 @@ +bodies-of-water/bodiesofwater_en.cxt: + title: Bodies of water + source: "Wille, R. (1984). Liniendiagramme hierarchischer Begriffssysteme. Studien zur Klassifikation. Indeks Verlag" + size: + objects: 8 + attributes: 6 + language: English + description: bodies of water and their properties + +bodies-of-water/bodiesofwater_de.cxt: + title: Gewässer + source: "Wille, R. (1984). Liniendiagramme hierarchischer Begriffssysteme. Studien zur Klassifikation. Indeks Verlag" + size: + objects: 8 + attributes: 6 + language: German + description: bodies of water and their properties + note: German version of bodiesofwater_en.cxt diff --git a/contexts/driveconcepts_de.cxt b/contexts/drive-concepts-for-motorcars/driveconcepts_de.cxt similarity index 100% rename from contexts/driveconcepts_de.cxt rename to contexts/drive-concepts-for-motorcars/driveconcepts_de.cxt diff --git a/contexts/driveconcepts_en.cxt b/contexts/drive-concepts-for-motorcars/driveconcepts_en.cxt similarity index 100% rename from contexts/driveconcepts_en.cxt rename to contexts/drive-concepts-for-motorcars/driveconcepts_en.cxt diff --git a/contexts/drive-concepts-for-motorcars/metadata.yaml b/contexts/drive-concepts-for-motorcars/metadata.yaml new file mode 100644 index 0000000..59188d2 --- /dev/null +++ b/contexts/drive-concepts-for-motorcars/metadata.yaml @@ -0,0 +1,19 @@ +drive-concepts-for-motorcars/driveconcepts_en.cxt: + title: Drive Concepts + source: "Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 39" + size: + objects: 5 + attributes: 25 + language: English + description: drive concepts for motorcars + note: "Derived from a table on page 402 in the book Schlag nach! 100000 Tatsachen aus allen Wissensgebieten. 13. Auflage. Meyers Lexikonverlag, 1988" + +drive-concepts-for-motorcars/driveconcepts_de.cxt: + title: Drive Concepts + source: "Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 39" + size: + objects: 5 + attributes: 25 + language: German + description: drive concepts for motorcars + note: German version of driveconcepts_en.cxt diff --git a/contexts/famous_animals_en.cxt b/contexts/famous-animals/famous_animals_en.cxt similarity index 100% rename from contexts/famous_animals_en.cxt rename to contexts/famous-animals/famous_animals_en.cxt diff --git a/contexts/famous-animals/metadata.yaml b/contexts/famous-animals/metadata.yaml new file mode 100644 index 0000000..ec59550 --- /dev/null +++ b/contexts/famous-animals/metadata.yaml @@ -0,0 +1,8 @@ +famous-animals/famous_animals_en.cxt: + title: Famous Animals + source: "Priss, U. (2006), Formal concept analysis in information science. Ann. Rev. Info. Sci. Tech., 40: 521-543. p.525" + size: + objects: 5 + attributes: 6 + language: English + description: famous animals and their characteristics diff --git a/contexts/livingbeings_de.cxt b/contexts/living-beings-and-water/livingbeings_de.cxt similarity index 100% rename from contexts/livingbeings_de.cxt rename to contexts/living-beings-and-water/livingbeings_de.cxt diff --git a/contexts/livingbeings_en.cxt b/contexts/living-beings-and-water/livingbeings_en.cxt similarity index 100% rename from contexts/livingbeings_en.cxt rename to contexts/living-beings-and-water/livingbeings_en.cxt diff --git a/contexts/living-beings-and-water/metadata.yaml b/contexts/living-beings-and-water/metadata.yaml new file mode 100644 index 0000000..3af3cab --- /dev/null +++ b/contexts/living-beings-and-water/metadata.yaml @@ -0,0 +1,18 @@ +living-beings-and-water/livingbeings_en.cxt: + title: Living Beings and Water + source: "Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 18" + size: + objects: 8 + attributes: 9 + language: English + description: conditions different living beings need + +living-beings-and-water/livingbeings_de.cxt: + title: Lebewesen und Wasser + source: "Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 18" + size: + objects: 8 + attributes: 9 + language: German + description: conditions different living beings need + note: German version of livingbeings_en.cxt diff --git a/contexts/miss-marple/metadata.yaml b/contexts/miss-marple/metadata.yaml new file mode 100644 index 0000000..ade279b --- /dev/null +++ b/contexts/miss-marple/metadata.yaml @@ -0,0 +1,18 @@ +miss-marple/missmarple_en.cxt: + title: Methods of murder in Miss Marple novels + source: "Schott, B. (2004). Schotts Sammelsurium. Bloomsbury, Berlin" + size: + objects: 12 + attributes: 6 + language: English + description: methods of murder in Miss Marple novels (not short stories!) + +miss-marple/missmarple_de.cxt: + title: Mordmethoden in Miss-Marple-Romanen + source: "Schott, B. (2004). Schotts Sammelsurium. Bloomsbury, Berlin" + size: + objects: 12 + attributes: 6 + language: German / English + description: methods of murder in Miss Marple novels (not short stories!) + note: German version of missmarple_en.cxt diff --git a/contexts/missmarple_de.cxt b/contexts/miss-marple/missmarple_de.cxt similarity index 100% rename from contexts/missmarple_de.cxt rename to contexts/miss-marple/missmarple_de.cxt diff --git a/contexts/missmarple_en.cxt b/contexts/miss-marple/missmarple_en.cxt similarity index 100% rename from contexts/missmarple_en.cxt rename to contexts/miss-marple/missmarple_en.cxt diff --git a/contexts/music-characteristics/metadata.yaml b/contexts/music-characteristics/metadata.yaml new file mode 100644 index 0000000..7333e40 --- /dev/null +++ b/contexts/music-characteristics/metadata.yaml @@ -0,0 +1,8 @@ +music-characteristics/music_en.cxt: + title: Music + source: "Ganter, B., Wille, R., & Stumme, G. (2005). Formal Concept Analysis: Foundations and Applications (Vol. 3626). Springer, p. 22" + size: + objects: 31 + attributes: 11 + language: English + description: music and their characteristics diff --git a/contexts/music_en.cxt b/contexts/music-characteristics/music_en.cxt similarity index 100% rename from contexts/music_en.cxt rename to contexts/music-characteristics/music_en.cxt diff --git a/contexts/new-zealand-activities/metadata.yaml b/contexts/new-zealand-activities/metadata.yaml new file mode 100644 index 0000000..2e5ce3f --- /dev/null +++ b/contexts/new-zealand-activities/metadata.yaml @@ -0,0 +1,8 @@ +new-zealand-activities/newzealand_en.cxt: + title: New Zealand Leasure + source: "DK Eyewitness Travel Guide New Zealand. Dorling Kindersley Publishing Inc. 2001." + size: + objects: 13 + attributes: 8 + language: English + description: Places in New Zealand and offered activities diff --git a/contexts/newzealand_en.cxt b/contexts/new-zealand-activities/newzealand_en.cxt similarity index 100% rename from contexts/newzealand_en.cxt rename to contexts/new-zealand-activities/newzealand_en.cxt diff --git a/contexts/office-supplies-and-services/metadata.yaml b/contexts/office-supplies-and-services/metadata.yaml new file mode 100644 index 0000000..9612576 --- /dev/null +++ b/contexts/office-supplies-and-services/metadata.yaml @@ -0,0 +1,18 @@ +office-supplies-and-services/officesupplies_en.cxt: + title: Office Supplies + source: "Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 25" + size: + objects: 8 + attributes: 5 + language: English + description: service offers of an office supplies business + +office-supplies-and-services/officesupplies_de.cxt: + title: Bürobedarf + source: "Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 25" + size: + objects: 8 + attributes: 5 + language: German + description: service offers of an office supplies business + note: German version of officesupplies_en.cxt diff --git a/contexts/officesupplies_de.cxt b/contexts/office-supplies-and-services/officesupplies_de.cxt similarity index 100% rename from contexts/officesupplies_de.cxt rename to contexts/office-supplies-and-services/officesupplies_de.cxt diff --git a/contexts/officesupplies_en.cxt b/contexts/office-supplies-and-services/officesupplies_en.cxt similarity index 100% rename from contexts/officesupplies_en.cxt rename to contexts/office-supplies-and-services/officesupplies_en.cxt diff --git a/contexts/planets/metadata.yaml b/contexts/planets/metadata.yaml new file mode 100644 index 0000000..874d811 --- /dev/null +++ b/contexts/planets/metadata.yaml @@ -0,0 +1,8 @@ +planets/planets_en.cxt: + title: Planets + source: "Anggraini, D. (2011). Analisis Perubahan Kelompok Berdasarkan Perubahan Nilai Jual Pada Bloomberg Market Data dengan Menggunakan Formal Concept Analysis, p. 7" + size: + objects: 9 + attributes: 7 + language: English + description: size and distance of planets diff --git a/contexts/planets_en.cxt b/contexts/planets/planets_en.cxt similarity index 100% rename from contexts/planets_en.cxt rename to contexts/planets/planets_en.cxt diff --git a/contexts/seasoning-planner/metadata.yaml b/contexts/seasoning-planner/metadata.yaml new file mode 100644 index 0000000..138a5e7 --- /dev/null +++ b/contexts/seasoning-planner/metadata.yaml @@ -0,0 +1,8 @@ +seasoning-planner/seasoningplanner_de.cxt: + title: Gewürzplaner + source: "Mahn, M. (2014). Gewürze: Das Standardwerk. Christian Verlag GmbH, München" + size: + objects: 56 + attributes: 37 + language: German + description: spices and herbs together and the meals they match diff --git a/contexts/seasoningplanner_de.cxt b/contexts/seasoning-planner/seasoningplanner_de.cxt similarity index 100% rename from contexts/seasoningplanner_de.cxt rename to contexts/seasoning-planner/seasoningplanner_de.cxt diff --git a/contexts/tea-ladies/metadata.yaml b/contexts/tea-ladies/metadata.yaml new file mode 100644 index 0000000..71cb698 --- /dev/null +++ b/contexts/tea-ladies/metadata.yaml @@ -0,0 +1,8 @@ +tea-ladies/tealady.cxt: + title: Tea Ladies + source: "Wille, R. (1992). Concept Lattices and Conceptual Knowledge Systems. Computers & Mathematics with Applications, 23, 6-9, p. 493-515" + size: + objects: 18 + attributes: 14 + language: + description: participation of social events by some ladies in Old City diff --git a/contexts/tealady.cxt b/contexts/tea-ladies/tealady.cxt similarity index 100% rename from contexts/tealady.cxt rename to contexts/tea-ladies/tealady.cxt diff --git a/merged-contexts-metadata.yaml b/merged-contexts-metadata.yaml new file mode 100644 index 0000000..413a08f --- /dev/null +++ b/merged-contexts-metadata.yaml @@ -0,0 +1,153 @@ +# This is the automatically merged metadata. Please do not modify it directly. +animals/animals_en.cxt: + description: animals and their characteristics + language: English + size: + attributes: 11 + objects: 35 + source: 'Ganter, B., Wille, R., & Stumme, G. (2005). Formal Concept Analysis: Foundations + and Applications (Vol. 3626). Springer, p. 27' + title: Animals +bodies-of-water/bodiesofwater_de.cxt: + description: bodies of water and their properties + language: German + note: German version of bodiesofwater_en.cxt + size: + attributes: 6 + objects: 8 + source: Wille, R. (1984). Liniendiagramme hierarchischer Begriffssysteme. Studien + zur Klassifikation. Indeks Verlag + title: Gewässer +bodies-of-water/bodiesofwater_en.cxt: + description: bodies of water and their properties + language: English + size: + attributes: 6 + objects: 8 + source: Wille, R. (1984). Liniendiagramme hierarchischer Begriffssysteme. Studien + zur Klassifikation. Indeks Verlag + title: Bodies of water +drive-concepts-for-motorcars/driveconcepts_de.cxt: + description: drive concepts for motorcars + language: German + note: German version of driveconcepts_en.cxt + size: + attributes: 25 + objects: 5 + source: Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 39 + title: Drive Concepts +drive-concepts-for-motorcars/driveconcepts_en.cxt: + description: drive concepts for motorcars + language: English + note: Derived from a table on page 402 in the book Schlag nach! 100000 Tatsachen + aus allen Wissensgebieten. 13. Auflage. Meyers Lexikonverlag, 1988 + size: + attributes: 25 + objects: 5 + source: Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 39 + title: Drive Concepts +famous-animals/famous_animals_en.cxt: + description: famous animals and their characteristics + language: English + size: + attributes: 6 + objects: 5 + source: 'Priss, U. (2006), Formal concept analysis in information science. Ann. + Rev. Info. Sci. Tech., 40: 521-543. p.525' + title: Famous Animals +living-beings-and-water/livingbeings_de.cxt: + description: conditions different living beings need + language: German + note: German version of livingbeings_en.cxt + size: + attributes: 9 + objects: 8 + source: Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 18 + title: Lebewesen und Wasser +living-beings-and-water/livingbeings_en.cxt: + description: conditions different living beings need + language: English + size: + attributes: 9 + objects: 8 + source: Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 18 + title: Living Beings and Water +miss-marple/missmarple_de.cxt: + description: methods of murder in Miss Marple novels (not short stories!) + language: German / English + note: German version of missmarple_en.cxt + size: + attributes: 6 + objects: 12 + source: Schott, B. (2004). Schotts Sammelsurium. Bloomsbury, Berlin + title: Mordmethoden in Miss-Marple-Romanen +miss-marple/missmarple_en.cxt: + description: methods of murder in Miss Marple novels (not short stories!) + language: English + size: + attributes: 6 + objects: 12 + source: Schott, B. (2004). Schotts Sammelsurium. Bloomsbury, Berlin + title: Methods of murder in Miss Marple novels +music-characteristics/music_en.cxt: + description: music and their characteristics + language: English + size: + attributes: 11 + objects: 31 + source: 'Ganter, B., Wille, R., & Stumme, G. (2005). Formal Concept Analysis: Foundations + and Applications (Vol. 3626). Springer, p. 22' + title: Music +new-zealand-activities/newzealand_en.cxt: + description: Places in New Zealand and offered activities + language: English + size: + attributes: 8 + objects: 13 + source: DK Eyewitness Travel Guide New Zealand. Dorling Kindersley Publishing Inc. + 2001. + title: New Zealand Leasure +office-supplies-and-services/officesupplies_de.cxt: + description: service offers of an office supplies business + language: German + note: German version of officesupplies_en.cxt + size: + attributes: 5 + objects: 8 + source: Ganter, B., & Wille, R. (1996). Formale Begriffsanalyse. Springer. p. 25 + title: Bürobedarf +office-supplies-and-services/officesupplies_en.cxt: + description: service offers of an office supplies business + language: English + size: + attributes: 5 + objects: 8 + source: Ganter, B., & Wille, R. (1999). Formal Concept analysis. Springer, p. 25 + title: Office Supplies +planets/planets_en.cxt: + description: size and distance of planets + language: English + size: + attributes: 7 + objects: 9 + source: Anggraini, D. (2011). Analisis Perubahan Kelompok Berdasarkan Perubahan + Nilai Jual Pada Bloomberg Market Data dengan Menggunakan Formal Concept Analysis, + p. 7 + title: Planets +seasoning-planner/seasoningplanner_de.cxt: + description: spices and herbs together and the meals they match + language: German + size: + attributes: 37 + objects: 56 + source: 'Mahn, M. (2014). Gewürze: Das Standardwerk. Christian Verlag GmbH, München' + title: Gewürzplaner +tea-ladies/tealady.cxt: + description: participation of social events by some ladies in Old City + language: null + size: + attributes: 14 + objects: 18 + source: Wille, R. (1992). Concept Lattices and Conceptual Knowledge Systems. Computers + & Mathematics with Applications, 23, 6-9, p. 493-515 + title: Tea Ladies diff --git a/scripts/merge_contexts_metadata.py b/scripts/merge_contexts_metadata.py new file mode 100644 index 0000000..1b460a7 --- /dev/null +++ b/scripts/merge_contexts_metadata.py @@ -0,0 +1,68 @@ +import os + +import yaml + +def merge_yaml_files(input_directory, output_file, comment=None): + """ + Merges all YAML files in the specified directory into a single YAML file. + + This function traverses the given input directory recursively, searching for + all files with a `.yaml` or `.yml` extension. It loads the contents of these + files and merges them into a single dictionary. The merged data is then written + to the specified output file. If a comment is provided, it will be added at + the top of the output YAML file. + + Parameters: + ----------- + input_directory : str + The path to the directory containing YAML files to merge. + output_file : str + The path where the merged YAML file will be saved. + comment : str (optional) + A comment to add at the top of the output YAML file. + Defaults to None, which means no comment will be added. + + Raises: + ------- + FileNotFoundError: + If the input directory does not exist. + yaml.YAMLError: + If there is an error reading any of the YAML files. + + Example: + -------- + >>> merge_yaml_files( + ... 'path/to/yaml/files', + ... 'merged_output.yaml', + ... comment='This is a merged YAML configuration', + ... ) + + Note: + ----- + The merged data will overwrite any existing content in the output file. + """ + merged_data = {} + + for root, _, files in os.walk(input_directory): + for file_name in files: + if file_name.endswith('.yaml') or file_name.endswith('.yml'): + file_path = os.path.join(root, file_name) + with open(file_path, mode='r') as f: + try: + data = yaml.safe_load(f) + merged_data = {**merged_data, **data} + except yaml.YAMLError as e: + print(f"Error reading {file_path}: {e}") + + with open(output_file, mode='w') as outfile: + if comment is not None: + outfile.write(f"# {comment}\n") + yaml.dump(merged_data, outfile, default_flow_style=False, allow_unicode=True) + + +if __name__ == "__main__": + input_dir = "contexts" + output_file = "merged-contexts-metadata.yaml" + comment = "This is the automatically merged metadata. Please do not modify it directly." + merge_yaml_files(input_dir, output_file, comment) + print(f"Merged YAML files into {output_file}")