Skip to main content

A Python library for e-filing systems.

Project description

libefiling

This library targets electronic filing data provided by the Japan Patent Office (JPO). Detailed documentation is written in Japanese, as the primary users are Japanese.

概要

libefiling は インターネット出願ソフトのアーカイブを扱う python パッケージです。

  • インターネット出願ソフト: 日本国特許庁に特許など出願する際に使うアプリ
  • アーカイブ: インターネット出願ソフトの「データ出力」で保存されるようなJWX(JPC,JWX)を本パッケージではそう呼んでる。
  • データ出力でアーカイブと一緒に出力されるXMLを手続XMLと呼ぶことにする。

機能

  • アーカイブの展開 -> XML, 画像ファイルが得られる
  • 画像ファイルのフォーマット変換、サイズ変換
  • XMLファイルの文字コード変換
  • いまのところ 特許願(A163) だけが処理対象。

動作環境

  • ubuntu bookworm
  • python 3.14
  • tesseract

必要アプリのインストール

apt-get update
apt-get install -y python3.14 tesseract-ocr tesseract-ocr-jpn

libefiling パッケージのインストール

pip install libefiling

使い方

from libefiling import parse_archive, ImageConvertParam, generate_sha256, get_document_code

params = [
    ImageConvertParam(
        width=300,
        height=300,
        suffix="-thumbnail",
        format=".webp",
        attributes=[{"key": "sizeTag", "value": "thumbnail"}],
    ),
    ImageConvertParam(
        width=600,
        height=600,
        suffix="-middle",
        format=".webp",
        attributes=[{"key": "sizeTag", "value": "middle"}],
    ),
    ImageConvertParam(
        width=800,
        height=0,
        suffix="-large",
        format=".webp",
        attributes=[{"key": "sizeTag", "value": "large"}],
    ),
]

SRC='202501010000123456_A163_____XXXXXXXXXX__99999999999_____AAA.JWX'
PROC='202501010000123456_A163_____XXXXXXXXXX__99999999999_____AFM.XML'
OUT='output'

### ocr 処理対象イメージの種類. 以下から選択
### OCR_TARGET = Literal[
###     "chemical-formulas", "figures", "equations", "tables", "other-images", "ALL"
### ]
ocr_target = ["other-images"]
doc_id = generate_sha256(SRC)
if doc_id === '...':
    print("Already processed")
else:
    parse_archive(SRC, PROC, OUT, params, ocr_target)

print(get_document_code("output/manifest.json"))
  • generate_sha256 はアーカイブの内容に応じたハッシュ値を生成し、再処理判定用に使える。
  • parse_archive は SRC,PROCを OUTに展開する。第4引数に、画像変換のパラメータを渡せる。 OUT に各種ファイルが展開される。第5引数はOCR処理対象の画像種別を選択する
  • get_document_code は parse_archive で生成された manifest.json のパスを与えると、文書コード(e.g. A163)を返す。

出力ファイル

  • manifest.json : 展開後のファイルの情報
  • raw/ : SRC に含まれてたファイルが展展されてる。
  • xml/ : raw/*.xml 、PROC を文字コード変換したxml, イメージ変換の対応を表したxml が保存されてる。
  • images/ : raw の画像ファイルがparamsに従って変換された画像が保存されてる。
  • ocr/ : raw の画像ファイルごとにOCR処理してえられたテキストが保存されてる。

注意事項

  • テストは十分でないので、いろいろバグあるとおもう。
  • 読み取り元のファイル(SRC,PROCに指定したファイル)や展開後のファイルは、どこかに送信されることはありません。ソースみてもらえば。
  • 本アプリで何らかの損害を被っても本アプリ作者は責任を負いません。

ライセンス

MIT ライセンス

Reference

特許庁 日本国特許庁電子文書交換標準仕様XML編 (抜粋版) https://www.jpo.go.jp/system/patent/gaiyo/sesaku/document/touroku_jyohou_kikan/shomen-entry-02jpo-shiyosho.pdf

変更履歴

0.1.40

  • manifest の形式変更
    • xml, image の path を filename にした。

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

libefiling-0.1.49.tar.gz (73.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

libefiling-0.1.49-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file libefiling-0.1.49.tar.gz.

File metadata

  • Download URL: libefiling-0.1.49.tar.gz
  • Upload date:
  • Size: 73.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for libefiling-0.1.49.tar.gz
Algorithm Hash digest
SHA256 a580a9f26718fd8e0e087d912eb87ea151b39d980cac7e9ebd78ea29eec9419d
MD5 ab31a8bdf116e670bf0ce427e23661f7
BLAKE2b-256 a421541009f90bb5f37bf415fc8304658333153e81b26a2020f1927aa173bab1

See more details on using hashes here.

File details

Details for the file libefiling-0.1.49-py3-none-any.whl.

File metadata

  • Download URL: libefiling-0.1.49-py3-none-any.whl
  • Upload date:
  • Size: 19.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for libefiling-0.1.49-py3-none-any.whl
Algorithm Hash digest
SHA256 9fe818d41d3a23b183b3d44d3e54077458ad382d1607506c9f4aa7d94c65920a
MD5 8f0dee02559bb2d8cfc3612fed0ee518
BLAKE2b-256 44e44e7dbc272a1cdd6d6599f375d10922fe4c850dcab00bb9d762eff1b011b8

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page