Work (Q2) -> Report Series (Q3) -> Report (Q4) -> Text Division (Q5) -> Chapter (Q6)
The graph logic in the ER model is defined through P3 = Part of and P4 = Parts. The live Wikibase is checked against that intended model in order to record what actually exists today, not to assume the whole hierarchy is present.
class_query =f'''PREFIX wd: <{ENTITY_NS}>PREFIX wdt: <{PROPERTY_NS}>SELECT ?class ?classLabel (COUNT(?item) AS ?count)WHERE {{ VALUES ?class {{ wd:Q2 wd:Q3 wd:Q4 wd:Q5 wd:Q6 }} OPTIONAL {{ ?item wdt:P1 ?class . }} SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}}}GROUP BY ?class ?classLabelORDER BY ?class'''sparql = build_sparql_client(SPARQL_ENDPOINT)sparql.setQuery(class_query)sparql.setReturnFormat(JSON)class_results = sparql.query().convert()class_rows = class_results.get("results", {}).get("bindings", [])class_df = pd.DataFrame([{k: v["value"] for k, v in row.items()} for row in class_rows])print(f"Class counts returned: {len(class_df)}")display(class_df)
Class counts returned: 5
class
classLabel
count
0
https://climatekg.tibwiki.io/entity/Q2
Work
2
1
https://climatekg.tibwiki.io/entity/Q3
Report Series
1
2
https://climatekg.tibwiki.io/entity/Q4
Report
7
3
https://climatekg.tibwiki.io/entity/Q5
Text Division
10
4
https://climatekg.tibwiki.io/entity/Q6
Chapter
87
Show code
hierarchy_model = pd.DataFrame([ {"level": 1, "class": "Q2", "label": "Work", "role": "top-level corpus"}, {"level": 2, "class": "Q3", "label": "Report Series", "role": "series container"}, {"level": 3, "class": "Q4", "label": "Report", "role": "report container"}, {"level": 4, "class": "Q5", "label": "Text Division", "role": "division / section"}, {"level": 5, "class": "Q6", "label": "Chapter", "role": "leaf content unit"},])hierarchy_view = hierarchy_model.copy()hierarchy_view["class_uri"] = hierarchy_view["class"].map(lambda v: f"{WIKIBASE_URL}/entity/{v}")hierarchy_view = hierarchy_view.merge( class_df.rename(columns={"class": "class_uri", "classLabel": "current_label", "count": "items_in_graph"}), on="class_uri", how="left")hierarchy_view["items_in_graph"] = pd.to_numeric(hierarchy_view["items_in_graph"], errors="coerce").fillna(0).astype(int)print("Canonical report hierarchy model vs current graph")display(hierarchy_view[["level", "label", "role", "items_in_graph"]].rename(columns={"label": "expected_label"}))print("This view shows the intended hierarchy from Work down to Chapter together with the live count of items currently represented in the graph.")
Canonical report hierarchy model vs current graph
level
expected_label
role
items_in_graph
0
1
Work
top-level corpus
2
1
2
Report Series
series container
1
2
3
Report
report container
7
3
4
Text Division
division / section
10
4
5
Chapter
leaf content unit
87
This view shows the intended hierarchy from Work down to Chapter together with the live count of items currently represented in the graph.
Relationship check
Note: this validation block is intentionally kept as a checkpoint. It confirms whether the live graph contains the expected P3 = Part of and P4 = Parts links before the hierarchy is interpreted more broadly. We will return to it when the model is checked against the current data.
This section is a follow-up validation step: it checks whether the graph actually contains the expected P3 / P4 structure that links the hierarchy together.
Show code
p3_query =f'''PREFIX wd: <{ENTITY_NS}>PREFIX wdt: <{PROPERTY_NS}>SELECT ?item ?itemLabel ?itemType ?itemTypeLabel ?parent ?parentLabelWHERE {{ ?item wdt:P3 ?parent . OPTIONAL {{ ?item wdt:P1 ?itemType . }} SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}}}ORDER BY ?itemLabelLIMIT 200'''p4_query =f'''PREFIX wdt: <{PROPERTY_NS}>SELECT ?parent ?parentLabel ?child ?childLabelWHERE {{ ?parent wdt:P4 ?child . SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}}}ORDER BY ?parentLabel ?childLabelLIMIT 200'''p3 = build_sparql_client(SPARQL_ENDPOINT)p3.setQuery(p3_query)p3.setReturnFormat(JSON)p3_results = p3.query().convert()p3_rows = p3_results.get("results", {}).get("bindings", [])p3_df = pd.DataFrame([{k: v["value"] for k, v in row.items()} for row in p3_rows])p4 = build_sparql_client(SPARQL_ENDPOINT)p4.setQuery(p4_query)p4.setReturnFormat(JSON)p4_results = p4.query().convert()p4_rows = p4_results.get("results", {}).get("bindings", [])p4_df = pd.DataFrame([{k: v["value"] for k, v in row.items()} for row in p4_rows])print("Direct P3 edges found:")display(p3_df)print("Direct P4 edges found:")display(p4_df)
Direct P3 edges found:
item
parent
itemType
itemLabel
itemTypeLabel
parentLabel
0
https://climatekg.tibwiki.io/entity/Q2089
https://climatekg.tibwiki.io/entity/Q10
https://climatekg.tibwiki.io/entity/Q2087
1.5DS
Acronym
Special Report: Global Warming of 1.5°C
1
https://climatekg.tibwiki.io/entity/Q1167
https://climatekg.tibwiki.io/entity/Q77
https://climatekg.tibwiki.io/entity/Q1
1.5°C pathway
Category
Working Group I: Climate Change 2021 – The Phy...
2
https://climatekg.tibwiki.io/entity/Q1167
https://climatekg.tibwiki.io/entity/Q150
https://climatekg.tibwiki.io/entity/Q1
1.5°C pathway
Category
Working Group III: Climate Change 2022 – Mitig...
3
https://climatekg.tibwiki.io/entity/Q1168
https://climatekg.tibwiki.io/entity/Q10
https://climatekg.tibwiki.io/entity/Q1
1.5°C warmer worlds
Category
Special Report: Global Warming of 1.5°C
4
https://climatekg.tibwiki.io/entity/Q1169
https://climatekg.tibwiki.io/entity/Q77
https://climatekg.tibwiki.io/entity/Q1
13C
Category
Working Group I: Climate Change 2021 – The Phy...
...
...
...
...
...
...
...
195
https://climatekg.tibwiki.io/entity/Q2660
https://climatekg.tibwiki.io/entity/Q35
https://climatekg.tibwiki.io/entity/Q2087
AWD
Acronym
Special Report: Climate Change and Land
196
https://climatekg.tibwiki.io/entity/Q3069
https://climatekg.tibwiki.io/entity/Q77
https://climatekg.tibwiki.io/entity/Q2087
AZM
Acronym
Working Group I: Climate Change 2021 – The Phy...
197
https://climatekg.tibwiki.io/entity/Q1172
https://climatekg.tibwiki.io/entity/Q77
https://climatekg.tibwiki.io/entity/Q1
Ablation
Category
Working Group I: Climate Change 2021 – The Phy...
198
https://climatekg.tibwiki.io/entity/Q1173
https://climatekg.tibwiki.io/entity/Q77
https://climatekg.tibwiki.io/entity/Q1
Abrupt change
Category
Working Group I: Climate Change 2021 – The Phy...
199
https://climatekg.tibwiki.io/entity/Q1173
https://climatekg.tibwiki.io/entity/Q106
https://climatekg.tibwiki.io/entity/Q1
Abrupt change
Category
Working Group II: Climate Change 2022 – Impact...
200 rows × 6 columns
Direct P4 edges found:
Full hierarchy contents
This table shows the items currently populating the report hierarchy, with their class, direct parent/child links, and the corresponding wiki page when it exists. It is the complete live view of the structure that the model describes.
Show code
full_hierarchy_query =f'''PREFIX wd: <{ENTITY_NS}>PREFIX wdt: <{PROPERTY_NS}>SELECT ?item ?itemLabel ?class ?classLabel ?parent ?parentLabel ?child ?childLabelWHERE {{ VALUES ?class {{ wd:Q2 wd:Q3 wd:Q4 wd:Q5 wd:Q6 }} ?item wdt:P1 ?class . OPTIONAL {{ ?item wdt:P3 ?parent . }} OPTIONAL {{ ?item wdt:P4 ?child . }} SERVICE wikibase:label {{ bd:serviceParam wikibase:language "en". }}}}ORDER BY ?class ?itemLabel'''full_hierarchy = build_sparql_client(SPARQL_ENDPOINT)full_hierarchy.setQuery(full_hierarchy_query)full_hierarchy.setReturnFormat(JSON)full_hierarchy_results = full_hierarchy.query().convert()full_hierarchy_rows = full_hierarchy_results.get("results", {}).get("bindings", [])full_hierarchy_df = pd.DataFrame([ {"class": None,"classLabel": None,"item": None,"itemLabel": None,"parent": None,"parentLabel": None,"child": None,"childLabel": None, } | {k: v["value"] for k, v in row.items()}for row in full_hierarchy_rows])ifnot full_hierarchy_df.empty: full_hierarchy_df["item_id"] = full_hierarchy_df["item"].str.rsplit("/", n=1, expand=True)[1] full_hierarchy_df["wiki_url"] = full_hierarchy_df["item_id"].map(lambda v: f"{WIKIBASE_URL}/wiki/Item:{v}") full_hierarchy_df["nested_structure"] = full_hierarchy_df.apply(lambda row: f"{row['parentLabel']} -> {row['itemLabel']}"if pd.notna(row.get('parentLabel')) else row['itemLabel'], axis=1, ) full_hierarchy_df = full_hierarchy_df[["classLabel","itemLabel","item","parent","item_id","wiki_url","parentLabel","childLabel","nested_structure", ]].rename(columns={'classLabel': 'class','itemLabel': 'name','item': 'item','parent': 'parent','item_id': 'P number','wiki_url': 'wiki_link','parentLabel': 'parent_label','childLabel': 'part','nested_structure': 'nested_structure', }) display(full_hierarchy_df)else:print("No items found for the canonical hierarchy in the current graph.")print("This table shows the live population of the report hierarchy and how each item is nested within it.")
class
name
item
parent
P number
wiki_link
parent_label
part
nested_structure
0
Work
IPCC Sixth Assessment Report
https://climatekg.tibwiki.io/entity/Q7
None
Q7
https://climatekg.tibwiki.io/wiki/Item:Q7
None
None
IPCC Sixth Assessment Report
1
Work
Report Series
https://climatekg.tibwiki.io/entity/Q3
None
Q3
https://climatekg.tibwiki.io/wiki/Item:Q3
None
None
Report Series
2
Report Series
IPCC Sixth Assessment Report
https://climatekg.tibwiki.io/entity/Q7
None
Q7
https://climatekg.tibwiki.io/wiki/Item:Q7
None
None
IPCC Sixth Assessment Report
3
Report
Climate Change 2023: Synthesis Report. Contrib...
https://climatekg.tibwiki.io/entity/Q189
https://climatekg.tibwiki.io/entity/Q7
Q189
https://climatekg.tibwiki.io/wiki/Item:Q189
IPCC Sixth Assessment Report
None
IPCC Sixth Assessment Report -> Climate Change...
4
Report
Special Report: Climate Change and Land
https://climatekg.tibwiki.io/entity/Q35
https://climatekg.tibwiki.io/entity/Q7
Q35
https://climatekg.tibwiki.io/wiki/Item:Q35
IPCC Sixth Assessment Report
None
IPCC Sixth Assessment Report -> Special Report...
...
...
...
...
...
...
...
...
...
...
102
Chapter
Tropical Forests
https://climatekg.tibwiki.io/entity/Q149
https://climatekg.tibwiki.io/entity/Q137
Q149
https://climatekg.tibwiki.io/wiki/Item:Q149
Cross-Chapter Papers (Text Division)
None
Cross-Chapter Papers (Text Division) -> Tropic...
103
Chapter
Urban Systems and Other Settlements
https://climatekg.tibwiki.io/entity/Q172
https://climatekg.tibwiki.io/entity/Q153
Q172
https://climatekg.tibwiki.io/wiki/Item:Q172
Chapters (Text Division)
None
Chapters (Text Division) -> Urban Systems and ...
104
Chapter
Water
https://climatekg.tibwiki.io/entity/Q116
https://climatekg.tibwiki.io/entity/Q110
Q116
https://climatekg.tibwiki.io/wiki/Item:Q116
Chapters (Text Division)
None
Chapters (Text Division) -> Water
105
Chapter
Water Cycle Changes
https://climatekg.tibwiki.io/entity/Q96
https://climatekg.tibwiki.io/entity/Q81
Q96
https://climatekg.tibwiki.io/wiki/Item:Q96
Chapters
None
Chapters -> Water Cycle Changes
106
Chapter
Weather and Climate Extreme Events in a Changi...
https://climatekg.tibwiki.io/entity/Q101
https://climatekg.tibwiki.io/entity/Q81
Q101
https://climatekg.tibwiki.io/wiki/Item:Q101
Chapters
None
Chapters -> Weather and Climate Extreme Events...
107 rows × 9 columns
This table shows the live population of the report hierarchy and how each item is nested within it.
Questions: Report structure
From the GitHub issue: https://github.com/TIBHannover/ClimateKG-Data-Bench/issues/1
Show me the full hierarchy of AR6, from the work down to its chapters.
Which chapters of the WGII report are licensed under CC-BY, and what are their DOIs?
For AR6 report items, retrieve licence (P11) and DOI (P10) details, including the licence link where present, and identify which reports are not Creative Commons.
Question 1
Show me the full hierarchy of AR6, from the work down to its chapters.
This view shows the full Report hierarchy, including Work and Report Series above the report entries.
Searchable nested hierarchy
This view turns the table into a readable hierarchy so a reader can quickly find a report part and trace its position in the corpus from the top-level work down to the chapter or section it belongs to.
For AR6 report items, retrieve licence (P11) and DOI (P10) details, including the licence link where present, and identify which reports are not Creative Commons.
Creative Commons status summary (distinct reports):
creative_commons_status
report_count
0
Creative Commons
6
1
Not clearly Creative Commons
1
Interpretation
The ER model recorded in The Rock defines the intended corpus structure: Q2 Work, Q3 Report Series, Q4 Report, Q5 Text Division, and Q6 Chapter. In that schema, P3 is the parent / part-of relationship and P4 is the child / parts relationship.
The live graph is now populated across the expected report hierarchy: class counts show items at all five levels, from Q2 through Q6. This means the graph is no longer a chapter-only snapshot and now contains a working structure that can be compared directly against the ER model.
The current data therefore supports a more nuanced conclusion: the graph reflects a genuinely populated report hierarchy, while the notebook continues to use the canonical ER model as the baseline for checking which entities and relationship patterns are present and how they fit together.