from iiif_tei_py.core import CoreClient
= CoreClient.load_env() cred_path
iiif_tei_py
A Python library for working with IIIF and TEI XML
Creating TEI/XML with results from OCR using Google Cloud Vision API
Install
pip install https://github.com/nakamura196/iiif_tei_py
Basic usage
Prepare .env
file
GOOGLE_APPLICATION_CREDENTIALS=your-google-credentials.json
Prepare Google Cloud Vision API credentials
Main
= "https://iiif.io/api/presentation/2.1/example/fixtures/resources/page1-full.png"
url = "./tmp/01/output.xml"
output_tei_xml_file_path ="Sample") CoreClient.create_tei_xml_with_gocr(url, output_tei_xml_file_path, cred_path, title
I0000 00:00:1723108517.494375 11044252 check_gcp_environment_no_op.cc:29] ALTS: Platforms other than Linux and Windows are not supported
Advanced usage
OCR with Google Cloud Vision API
URL
from iiif_tei_py.core import IIIFClient
= IIIFClient(cred_path)
iiif = "./tmp/02/output.json"
iiif_manifest_file_path ="./tmp", title="Sample") iiif.create_manifest3_by_gocr(url, iiif_manifest_file_path, tmp_dir
I0000 00:00:1723108518.636803 11044252 check_gcp_environment_no_op.cc:29] ALTS: Platforms other than Linux and Windows are not supported
Local file
= "./tmp/03/output.json"
iiif_manifest_file_path_local = "./tmp/02/images/demo.jpg"
input_image_file_path ="Sample") iiif.create_manifest3_local_by_gocr(input_image_file_path, iiif_manifest_file_path_local, title
I0000 00:00:1723108519.684659 11044252 check_gcp_environment_no_op.cc:29] ALTS: Platforms other than Linux and Windows are not supported
Convert IIIF manifest to TEI/XML
from iiif_tei_py.core import TEIClient
= TEIClient()
teiClient = "./tmp/04/output.xml"
output_tei_xml_file_path teiClient.convert_manifest3_annotations_to_zones(iiif_manifest_file_path, output_tei_xml_file_path)