Skip to main content

Chinese→Russian ID terms dictionary (places, authorities, surname/given-name rules) with a bundled SQLite DB.

Project description

zh2ru-idterms

中文证件(护照 / 驾驶证)用名词的中俄对照库(SQLite 版)。
内置 terms.db 数据库,开箱即用:地理名词、机构名称(按证件类型区分)、中文姓名拼音转俄文(帕拉第乌斯转写)

0.1.2 版本特性:

  • 全部存入数据库,不再额外提供Palladius转写,之前版本有错误。

安装

pip install zh2ru-idterms

无需任何 CLI、无需传入数据库路径,包内已自带 terms.db


快速使用

from zh2ru_idterms import (
    get_place_path,
    find_surname_pinyin,
    to_palladius_given,
    translate_person_name,
    find_org,
)

# 1) 地理名词:支持简称或全称
print(get_place_path(province_zh="浙江省"))      # {'province': 'Чжэцзян'}
print(get_place_path(province_zh="浙江"))        # {'province': 'Чжэцзян'}
print(get_place_path(city_zh="宁波市"))          # {'province': 'Чжэцзян', 'city': 'Нинбо'}
print(get_place_path(city_zh="宁波", district_zh="鄞州区"))
# -> {'province': 'Чжэцзян', 'city': 'Нинбо', 'district': 'Иньчжоу'}

# 2) 姓氏:拼音 → 俄文
print(find_surname_pinyin("zhang"))              # чжан

# 3) 名(给定拼音 → Palladius 转写)
print(to_palladius_given("xiaoming"))            # сяомин

# 4) 中文姓名(拼音形式) → 俄文全名
print(translate_person_name("zhang", "xiaoming"))# Чжан Сяомин

# 5) 机构名称(按证件类型)
print(find_org("国家移民管理局", doc_type="passport"))
# {'name_zh': '国家移民管理局', 'name_ru': 'Государственное управление по делам иммиграции КНР', ...}

get_place_path 参数说明

  • province_zh: 省/自治区/直辖市(全称或简称都可,如“浙江省”/“浙江”,“广西壮族自治区”/“广西”)
  • city_zh: 地级市(可写“宁波市”或“宁波”)
  • district_zh: 区/县(如“鄞州区”“鄞州”)

支持部分层级

  • 只给 province_zh:返回 {province: ...}
  • city_zh 不给 province_zh:全库搜索城市,若唯一命中,返回省市
  • 只给 district_zh:全库搜索区县,若唯一命中,返回省市区

若同名多地命中(模糊情况),将返回 None,请提供更精确的上级以消歧。


API 一览(保持兼容旧用法)

  • get_place_path(province_zh=None, city_zh=None, district_zh=None) -> Optional[dict]
  • find_surname_pinyin(pinyin: str) -> Optional[str]
  • to_palladius_given(pinyin_text: str) -> str
  • translate_person_name(surname_pinyin: str, given_pinyin: str) -> str
  • find_org(name_zh: str, doc_type: str = "passport", region_zh: Optional[str] = None) -> Optional[dict]

机构:doc_type 建议使用 "passport""driving_licence"


数据库说明

包内置 data/terms.db,结构包含:

  • geo_province / geo_city / geo_district
  • authority_org(机构,按 doc_type 区分)
  • surname_pinyin_rule(姓:拼音→俄文)
  • (可选)surname_rule / givenname_rule / name_exception(未必在你的数据集中启用)

运行时会检测 aliases_zh 列是否存在;不存在时不影响使用,仅降级为 name_zh LIKE 模糊匹配。


扩展与自定义数据

如果你有自己的数据导入,请在外部工具中导入同名表到你的 SQLite,再替换包内 terms.db 即可。
(或在你的程序中通过 importlib.resources.files('zh2ru_idterms')/'data/terms.db' 找到路径,进行覆盖。)


版本记录

  • 0.1.1
    • 省份/自治区简称支持(浙江/广西等)
    • 兼容无 aliases_zh 列的数据库(自动降级匹配)
  • 0.1.0
    • 初始版本,内置 terms.db 与核心 API

许可证

MIT

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

zh2ru_idterms-0.1.2.tar.gz (37.7 kB view details)

Uploaded Source

Built Distribution

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

zh2ru_idterms-0.1.2-py3-none-any.whl (36.0 kB view details)

Uploaded Python 3

File details

Details for the file zh2ru_idterms-0.1.2.tar.gz.

File metadata

  • Download URL: zh2ru_idterms-0.1.2.tar.gz
  • Upload date:
  • Size: 37.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for zh2ru_idterms-0.1.2.tar.gz
Algorithm Hash digest
SHA256 218b3c7d3b5b4f5e6abc82357b8b8e0cb9ada5374fb77fd63a63d805088a306c
MD5 2c615451fb68185153f61dc9cc2560db
BLAKE2b-256 48da892a04e920e6d2bfd1a96bab8f42c5f91d6f7aeb9c07b02fe3e927b804ea

See more details on using hashes here.

File details

Details for the file zh2ru_idterms-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: zh2ru_idterms-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 36.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.11.13

File hashes

Hashes for zh2ru_idterms-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8e3282caff70414ea743c2e57e9b2bea02ab81eda4884b14aa4e4c16c76ed82e
MD5 11872064f23c717d8ed0bf69de39b9f1
BLAKE2b-256 d48d81711805882076bc21966119c0972dfed47f1ca78db9671be8fcee9e6469

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