ホーム 記事一覧 ブック DH週間トピックス 検索 このサイトについて
English
Mirador3プラグイン開発: Text Overlay pluginで縦書き対応を行う

Mirador3プラグイン開発: Text Overlay pluginで縦書き対応を行う

概要 Text Overlay plugin for Mirador 3は、OCRまたはトランスクリプションに基づいて選択可能なテキストオーバーレイを表示するMirador3のプラグインです。 https://github.com/dbmdz/mirador-textoverlay 以下でデモページが公開されています。 https://mirador-textoverlay.netlify.app/ 一方、日本語などの縦書きテキストを表示してみると、以下のようにうまく表示ができませんでした。 そこで、上記のリポジトリをフォークして、縦書きテキストも表示できるようにしました。以下のリポジトリでソースコードを公開しています。(いずれプルリクエストも検討したいと思います。) https://github.com/nakamura196/mirador-textoverlay 結果、以下のように縦書きテキストも表示できるようになりました。 デモページは以下です。 https://nakamura196.github.io/mirador-integration-textoverlay/?manifest=https://nakamura196.github.io/static/iiif/6722fa34-2fff-11ee-a029-0242ac1c000c/manifest_o.json&annotationState=1&canvasIndex=3 以下、本モジュール開発に関連する事項をメモします。 マニフェストファイルの構造 本モジュールでは、以下の要件を満たすIIIFマニフェストが必要とのことでした。 https://github.com/dbmdz/mirador-textoverlay#requirements-for-supported-iiif-manifests いくつかのオプションがありますが、以下のwellcome collectionのマニフェストを参考にしました。 https://iiif.wellcomecollection.org/presentation/v2/b18035723 Canvas毎にseeAlsoでALTO XMLファイルへのURLが指定されています。 { "@id": "https://iiif.wellcomecollection.org/presentation/b18035723/canvases/b18035723_0003.JP2", "@type": "sc:Canvas", "label": "-", "thumbnail": { "@id": "https://iiif.wellcomecollection.org/thumbs/b18035723_0003.JP2/full/72,100/0/default.jpg", "@type": "dctypes:Image", "service": { "@context": "http://iiif.io/api/image/2/context.json", "@id": "https://iiif.wellcomecollection.org/thumbs/b18035723_0003.JP2", "profile": "http://iiif.io/api/image/2/level0.json", "protocol": "http://iiif.io/api/image", "width": 732, "height": 1024, "sizes": [ { "width": 72, "height": 100 }, { "width": 143, "height": 200 }, { "width": 286, "height": 400 }, { "width": 732, "height": 1024 } ] } }, "seeAlso": { "@id": "https://api.wellcomecollection.org/text/alto/b18035723/b18035723_0003.JP2", "profile": "http://www.loc.gov/standards/alto/v3/alto.xsd", "format": "text/xml", "label": "METS-ALTO XML" }, "height": 3372, "width": 2411, "images": [ { "@id": "https://iiif.wellcomecollection.org/presentation/b18035723/canvases/b18035723_0003.JP2/painting/anno", "@type": "oa:Annotation", "motivation": "sc:painting", "resource": { "@id": "https://iiif.wellcomecollection.org/image/b18035723_0003.JP2/full/732,1024/0/default.jpg", "@type": "dctypes:Image", "format": "image/jpeg", "height": 1024, "width": 732, "service": { "@context": "http://iiif.io/api/image/2/context.json", "@id": "https://iiif.wellcomecollection.org/image/b18035723_0003.JP2", "profile": "http://iiif.io/api/image/2/level1.json", "protocol": "http://iiif.io/api/image", "width": 2411, "height": 3372 } }, "on": "https://iiif.wellcomecollection.org/presentation/b18035723/canvases/b18035723_0003.JP2" } ], "otherContent": [ { "@id": "https://iiif.wellcomecollection.org/annotations/v2/b18035723/b18035723_0003.JP2/line", "@type": "sc:AnnotationList", "label": "Text of page -" } ], "within": "" } まとめ 開発したプラグインについて、xmlファイルのロードが完了しない時があるなど、引き続き改善が必要ですが、Mirador3のプラグイン開発やIIIF、OCR結果の活用にあたり、参考になりましたら幸いです。 ...

ALTO (Analyzed Layout and Text Object) XMLについて

ALTO (Analyzed Layout and Text Object) XMLについて

概要 ALTO (Analyzed Layout and Text Object) XMLについて、GPT-4に問い合わせた結果を共有します。 https://www.loc.gov/standards/alto/ 必須項目 ALTO (Analyzed Layout and Text Object) XMLは、OCR生成テキストとそのレイアウトを表現するためのXMLスキーマです。その構造は非常に柔軟で、多くの要素と属性が存在しますが、必須の要素は限られています。 最も単純な形式のALTO XMLは、以下のような階層構造を持ちます: <alto>: ルート要素です。ALTO XMLスキーマのバージョンを示す@xmlns属性と@xmlns:xsi属性を持つ必要があります。また、<Description>と<Layout>という二つの子要素を持つ必要があります。 <Description>: ファイルのメタデータを含みます。この要素自体に必須の子要素はありませんが、通常、<MeasurementUnit>, <sourceImageInformation>や<OCRProcessing>などの子要素を含むでしょう。 <Layout>: ファイルの物理的なレイアウトを表現します。これは<Page>という子要素を1つ以上含む必要があります。 <Page>: 一つのページを表現します。この要素は@IDと@WIDTHと@HEIGHTという三つの必須属性を持つべきです。また、<PrintSpace>という子要素を1つ持つことができます。 上記の要素はALTO XMLの最も基本的な構造を表現していますが、テキストの内容やそのレイアウトを詳細に表現するためには、さらに多くの要素と属性を使用することが可能です。例えば、<PrintSpace>, <TextBlock>, <TextLine>, <String>などの要素を使用することで、テキストの物理的な配置や内容を詳細に表現することができます。それぞれの要素や属性の詳細については、ALTO XMLスキーマのドキュメンテーションを参照してください。 OCRProcessing要素 OCRProcessing要素は、ALTO XML内の<Description>エレメント内で使用されます。この要素は、特定のOCRプロセスに関する情報を格納します。それは以下のサブ要素を持つことができます: ocrProcessingStep: OCR処理の各ステップを記述します。この要素は processingDateTime, processingAgency, processingSoftware, processingStepSettings, processingStepDescriptionといった属性を持つことができます。 以下に、OCRProcessingエレメントの使用例を示します: <Description> ... <OCRProcessing ID="OCR1"> <ocrProcessingStep> <processingDateTime>2023-08-01T00:00:00</processingDateTime> <processingAgency>Agency Name</processingAgency> <processingSoftware> <softwareCreator>Software Creator Name</softwareCreator> <softwareName>Software Name</softwareName> <softwareVersion>Software Version</softwareVersion> </processingSoftware> <processingStepSettings>Settings</processingStepSettings> <processingStepDescription>Description of the processing step</processingStepDescription> </ocrProcessingStep> </OCRProcessing> ... </Description> ここで、processingDateTimeはOCR処理が行われた日時を表し、processingAgencyはその処理を行った機関名を表します。processingSoftwareはOCR処理に使用されたソフトウェアに関する情報を含み、processingStepSettingsとprocessingStepDescriptionはそれぞれ設定と処理手順の説明を提供します。 ...