annotation_specs list_annotation_import_info: 出力する情報に日本語名も含める - #1714
Conversation
Titlefeat: 日本語名を追加し、インポート情報の出力を強化 Description
Changes walkthrough 📝
|
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
annotation_specs list_annotation_import_info: 出力する情報に日本語名も含める
| result.append( | ||
| AnnotationImportAttribute( | ||
| attribute_name_en=get_attribute_name_en(attribute), | ||
| attribute_name_ja=get_message_with_lang(attribute["name"], Lang.JA_JP), |
There was a problem hiding this comment.
Suggestion: 属性の日本語名が存在しない場合に英語名に戻るよう、or get_attribute_name_en(attribute)を追加してください。 [general, importance: 5]
| attribute_name_ja=get_message_with_lang(attribute["name"], Lang.JA_JP), | |
| attribute_name_ja=get_message_with_lang(attribute["name"], Lang.JA_JP) or get_attribute_name_en(attribute), |
| return [ | ||
| AnnotationImportChoice( | ||
| choice_name_en=get_choice_name_en(choice), | ||
| choice_name_ja=get_message_with_lang(choice["name"], Lang.JA_JP), |
There was a problem hiding this comment.
Suggestion: 選択肢の日本語名が取得できない場合に備えて、or get_choice_name_en(choice)による英語フォールバックを追加してください。 [general, importance: 5]
| choice_name_ja=get_message_with_lang(choice["name"], Lang.JA_JP), | |
| choice_name_ja=get_message_with_lang(choice["name"], Lang.JA_JP) or get_choice_name_en(choice), |
There was a problem hiding this comment.
Pull request overview
annotation_specs list_annotation_import_info のJSON出力に日本語名(ラベル/属性/選択肢)を含め、annotation import 用の英語名との対応関係を把握しやすくするためのPRです。
Changes:
list_annotation_import_infoの出力モデルにlabel_name_ja/attribute_name_ja/choice_name_jaを追加- 追加フィールドの取得に
get_message_with_lang(..., Lang.JA_JP)を利用 - コマンドリファレンスの出力例と項目説明を更新し、テストにも新フィールドの検証を追加
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| annofabcli/annotation_specs/list_annotation_import_info.py | 出力スキーマに日本語名フィールドを追加し、アノテーション仕様から日本語名を抽出するよう拡張 |
| docs/command_reference/annotation_specs/list_annotation_import_info.rst | 日本語名が出力される旨とJSON例・項目説明を追記 |
| tests/annotation_specs/test_list_annotation_import_info.py | 追加された日本語名フィールドの検証を追加 |
Suppressed comments (4)
annofabcli/annotation_specs/list_annotation_import_info.py:85
get_message_with_lang()の第2引数を位置引数で渡していますが、リポジトリ内の他の呼び出し箇所は一貫してlang=のキーワード引数を使っています(例:list_annotation_specs_label.pyなど)。get_message_with_langがlangをキーワード専用にしている場合に実行時エラーになるので、ここもlang=Lang.JA_JPに揃えるのが安全です。
This issue also appears in the following locations of the same file:
- line 97
- line 107
dict_attribute = {attribute["additional_data_definition_id"]: attribute for attribute in annotation_specs_v3["additionals"]}
annofabcli/annotation_specs/list_annotation_import_info.py:107
get_message_with_lang()のlangはキーワード引数で渡す呼び出し方に統一してください(他のannotation_specs系コマンドと揃える/キーワード専用シグネチャでも動くようにするため)。
)
annofabcli/annotation_specs/list_annotation_import_info.py:97
get_message_with_lang()のlang引数は、他ファイルと同様にlang=...のキーワード引数で渡したほうが安全です(キーワード専用シグネチャの場合に備えられます)。
result = []
tests/annotation_specs/test_list_annotation_import_info.py:37
- ここも
ja-JPの message が英語名と同一(bike/"bike")なので、label_name_jaの言語選択を実質的に検証できていません。英語名と異なる日本語名(例: "自転車")に差し替えた上で期待値も更新すると、回帰検出力が上がります。
bike_label = next(e for e in actual if e.label_name_en == "bike")
assert bike_label.label_name_ja == "bike"
assert bike_label.annotation_type == "bounding_box"
| car_label = next(e for e in actual if e.label_name_en == "car") | ||
| assert car_label.label_name_ja == "car" | ||
| assert car_label.annotation_type == "bounding_box" | ||
| assert [e.attribute_name_en for e in car_label.attributes] == ["comment", "link", "type", "unclear"] | ||
| assert [e.attribute_name_ja for e in car_label.attributes] == ["comment", "link", "type", "unclear"] |
変更内容
annotation_specs list_annotation_import_infoの出力に、日本語名を追加しました。label_name_jaを追加attribute_name_jaを追加choice_name_jaを追加背景
annotation importで指定する値は英語名ですが、Coding AgentやLLMに変換処理を依頼する際、プロンプト上では日本語名を参照するケースがあります。日本語名を出力に含めることで、ラベル名・属性名・選択肢名の対応関係を把握しやすくし、アノテーション変換スクリプトやプロンプトを作成しやすくします。
確認内容
make formatmake lintuv run pytest tests/annotation_specs/test_list_annotation_import_info.py