Modules
Core modules
Koha
Koha scripts for processing MARC files and interacting with API.
Oauth2 session
In order to interact with your Koha API you will need to create a Client ID and Secret Key for your Koha admin user. Follow the offical documentation in order to generate Client and Secret keys for your user.
GET metadata from Koha
There are two main serializations for the MARC metadata of records and authorities that the Koha API provides: a detailed MARC in JSON dictionary serialization and a standard JSON serialization.
- Get authority record metadata from Koha API as MARC-in-JSON
- Get authority record metadata from Koha API as JSON
- Get bibliographic record metadata from Koha API as MARC-in-JSON
- Get bibliographic record metadata from Koha API as JSON
PUT metadata to Koha
Import bibliographic and authority catalogue
In order to import the whole catalogue, we provide two methods:
- Batch import from pre-downloaded MARC file from
Cataloging/Stage record for import. See import_koha_authorities_from_marc and import_koha_biblios_from_marc. - Batch import via API with parallel processing. See import_koha_authorities_from_api and import_koha_biblios_from_api.
Utilities
The module provides a series of functions that will extract specific fields from the MARC-in-JSON dictionary, such as
- item type
- authority type
- Wikidata entities associated to an authority
- umbrella terms associated to an authority
- main heading associated to an authority
- alternative headings (variant spelling and translations)
- explicit_abbreviations_from_marc: makes abbreviation codes explicit via mappings stored in
./data/mappings/abbreviations.
Enhancing modules
Wikidata
This module provides a way to programmatically interact with Wikidata or another Wikibase instance. It is mostly based on WikibaseIntegrator and requires specific username-password or API keys credentials.
Authentication
In order to avoid Too Many Requests errors from the API endpoint, we advise to create an account on Wikidata (or another Wikibase instance).
- Authenticate to Wikidata or Wikibase instance via username and password
- Authenticate via Oauth2 credentials. See official documentation for more information.
Enhancing Authorities
These scripts provide a controlled way to enrich your catalogue's authorities from Wikidata or another Wikibase instance.
- Ingest Wikidata URIs from OpenRefine reconciliation, see the tutorials page for more information.
- Add metadata from authority's external URIs field, such as source name, entity label (Wikidata only) and id value. You can customize the external sources list via
data/mappings/lod/external_identifiers.jsonmapping. - Enhance authorities via Wikidata properties by establishing a mapping between properties and umbrella terms. The mapping CSV is available at
data/mappings/wikidata/wikidata-koha-properties.csv.
The methods do not direct update the Koha catalogue. Instead, they generate backup_auth and changed_auth lists of dictionaries which are stored locally as JSON files. Once the user has manually checked the integrity of the data via sampling, the new records can be updated via pyreslib.wikidata.update_enhanced_authorities.
Mapping Wikidata properties URIs
In order to specify a relation statement between two authorites in our Koha catalogue, we have found a solution by recording the property's URI (such as [country][http://wikidata.org/entity/P17]) via a new subfield i, not belonging to the standard MARC21 framework for field 024.
To facilitate readibility of the URIs, we have created a new Authorized value group called RELATION_PROPERTY, associating each URI to the property name.
Google Books
This module allows to harvest metadata information from the Google Books API via ISBN of the book. This is useful if you wish to populate your new record with basic metadata by only providing the ISBN code in field 020. A mapping between Google and Koha fields is available in data/mappins/google.
Transkribus
This module allows the user to interact with the Transkribus API directly on Python. Transkribus is a state-of-the-art Handwritten Text Recognition platform for Digital Humanities scholars.
- Transkribus API login provinding username and password via
data/credentials/credentials.json. - Extract document metadata
- Get PAGEXML transcription of page
- Get plain text transcription of page
- Upload transcription via local PAGEXML file
Kraken
Kraken is an open-source OCR and HTR software built in Python. Because of its size, we have set its dependencies as optional and you have to build them manually via uv or pip.
uv add pyreslib[ocr] # uv
pip install pyreslib[ocr] # pip
Conversion modules
MARC
This module allows to process MARC files and records with the help of pymarc. It provides methods to convert MARC records to JSON dictionaries and vice versa, as well as to extract and modify specific information from MARC records.
- Convert MARC file to MARC-in-JSON dictionary for Koha API
- [Convert MARC file into plain text][pyreslib.marc.marc2txt]
- Convert MARC file into CSV
- Convert CSV file to MARC for ingestion based on template in
data/biblio_id/csv.
BibTeX
This modules allows the export of bibliographic records in BibTeX format, improving the built-in Koha export feature.
RDF
This module provides a series of scripts in order to export Koha record to RDF data structures using the RDFlib Python package.
Omeka S
Still in development...
ResourceSpace
Still in development...