- Jupyter Notebook 99.8%
- Python 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
| data | ||
| images | ||
| notebooks | ||
| .gitignore | ||
| .python-version | ||
| pyproject.toml | ||
| README.md | ||
| uv.lock | ||
Political Party Pipeline
This repository contains all the necessary code to convert the CSV Party Atlas from the project Année Politique Suisse from the University of Bern for two different outlets:
- a LINDAS Shared Dimension in RDF format using the version.link schema
- an I14Y Concept
Methodology
The conversion is done by using Jupyter notebooks in the folder notebooks. The code is intentionally quite verbose and not optimized for performance, as the main goal is to have a clear and understandable code that can be easily modified and extended.
1_json.ipynbdownloads and converts the multiple CSV files from the University of Bern into multiple JSON files.2a_I14Y.ipynbcontains all the necessary code to convert the JSON files from1_json.ipynbinto an I14Y concept and upload it to the I14Y platform. It also contains the logic to decide whether a new version of the concept needs to be pushed to the I14Y platform or not.2b_LINDAS.ipynbcontains all the necessary code to convert the JSON files from1_json.ipynbinto a LINDAS Shared Dimension in RDF according to the version.link schema and upload it to the LINDAS platform.3_queries.ipynbcontains some example queries to work with the LINDAS data.4_delete.ipynbcontains the code to delete the data from LINDAS (I14Y data can be deleted via Web UI).
version.link
The RDF data of the political parties is modeled using the version.link schema. The main idea of this schema is to have both a representation of the current state of the party, but also a representation of the historical changes of the party.
Each party exists as one vl:Identity with a unique ID. The vl:Identity represents the current state of the party. The historical changes of the party are represented as vl:Version instances. The following changes trigger the creation of a new vl:Version instance:
- the party changes its name
- the party starts or stops being a child of another party
- the party starts or stops being an observer in another party
- the party starts or stops being affiliated with another party
- the party is involved in a successor-of, split-from or accessed event
The vl:Version instances also have a unique ID built from the party's ID and the starting date of the version.
Changes to the "pure" version.link schema
The original idea of the version.link schema is, that all the information on the vl:Identiy is coming from a vl:Version. This is not the case in the political party data. The vl:Identity contains information that is not available in a versioned form. An example would be some alternate identifiers.
Relationships and Events
The original data in the relationship.csv file contains data that are from a version.link perspective two different types of relationships: Such events that have a start and stop date (e.g. "child of", "observer in", "affiliated with") and events that are instantaneously one-time events (e.g. "successor of", "split from", "accessed").
The solution chosen here is to create events from the relationships so that e.g a "child of" relationship results in a child-of-start-event and a child-of-stop-event. On the other hand, a "successor of" relationship results only in one event. Each vl:Version is started and stopped by events (can be multiple events for starting and stopping a vl:Version). Furthermore, name changes are also represented as events (name-change-start-event and name-change-stop-event).
Hierarchies
Versioned data in a hierarchical structure is potentially complex. If a new relationship (e.g. child-of) triggers also on the parent side a new version, this changed parent version will consequently also trigger new versions on all children. This leads to a not very useful cascade of new versions. Therefore, the approach chosen here is to create only a new version on the lower hierarchy level (e.g. on the child level). The link to the parent will be done to the vl:Identity and not to the vl:Version of the parent.
Alternative Rejected Approach
An alternative approach would be to have only one version per identity. The version has got all the history, the identity only the currently valid data. This would resemble more of a "Wikidata" approach.
The problem with such an approach is, that this would make it difficult to build vl:successor and vl:predecessor relationships, because the vl:successor can be the same party (if a split happens, the new party is one of the followers, but the existing party is also a follower, because it is still existing). This is difficult to model with only one version per identity.
Instructional Examples
In this section, some instructional examples of the data are listed. The examples are chosen to show the different types of relationships and events that can happen in the political party data. These examples can be understood best with the help of the version.link schema and the following image.
Successor-of Event
Two in, one out:
- Event: https://politics.ld.admin.ch/political-party/event/4e7104e5
- Version A in: https://politics.ld.admin.ch/political-party/version/11_1936-12-23
- Version B in: https://politics.ld.admin.ch/political-party/version/18_1941-12-15
- Version out: https://politics.ld.admin.ch/political-party/version/1_1971-09-22
One in, two out:
- Event: https://politics.ld.admin.ch/political-party/event/ccf300d4
- Version in: https://politics.ld.admin.ch/political-party/version/122_1986-06-17
- Version A out: https://politics.ld.admin.ch/political-party/version/110_1988-06-27
- Version B out: https://politics.ld.admin.ch/political-party/version/80_1988-06-27
Accessed Event
- Event: https://politics.ld.admin.ch/political-party/event/34a306e8
- Accessing Version: https://politics.ld.admin.ch/political-party/version/248_1917-07-01
- Accessed Version before: https://politics.ld.admin.ch/political-party/version/2_1921-03-06
- Accessed Version after: https://politics.ld.admin.ch/political-party/version/2_1925-07-01
Split-from Event
- Event: https://politics.ld.admin.ch/political-party/event/b6e9d0d6
- Version before: https://politics.ld.admin.ch/political-party/version/1_1971-09-22
- Version after: https://politics.ld.admin.ch/political-party/version/1_2008-11-01
- Split-off Version after: https://politics.ld.admin.ch/political-party/version/13_2008-11-01