Skip to content

annotation_specs list_annotation_import_info: 出力する情報に日本語名も含める - #1714

Merged
yuji38kwmt merged 2 commits into
mainfrom
20260802
Aug 2, 2026
Merged

annotation_specs list_annotation_import_info: 出力する情報に日本語名も含める#1714
yuji38kwmt merged 2 commits into
mainfrom
20260802

Conversation

@yuji38kwmt

@yuji38kwmt yuji38kwmt commented Aug 2, 2026

Copy link
Copy Markdown
Collaborator

変更内容

annotation_specs list_annotation_import_info の出力に、日本語名を追加しました。

  • ラベル情報に label_name_ja を追加
  • 属性情報に attribute_name_ja を追加
  • 選択肢情報に choice_name_ja を追加

背景

annotation import で指定する値は英語名ですが、Coding AgentやLLMに変換処理を依頼する際、プロンプト上では日本語名を参照するケースがあります。

日本語名を出力に含めることで、ラベル名・属性名・選択肢名の対応関係を把握しやすくし、アノテーション変換スクリプトやプロンプトを作成しやすくします。

確認内容

  • make format
  • make lint
  • uv run pytest tests/annotation_specs/test_list_annotation_import_info.py

Copilot AI review requested due to automatic review settings August 2, 2026 07:57
@kci-pr-agent

kci-pr-agent Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Title

feat: 日本語名を追加し、インポート情報の出力を強化


Description

  • annotation import情報に日本語名出力対応を追加

  • get_message_with_langとLangで日本語名を取得

  • テストに日本語名検証を追加

  • ドキュメントと例に日本語名項目を追加


Changes walkthrough 📝

Relevant files
Enhancement
list_annotation_import_info.py
日本語名フィールド追加および取得ロジック更新                                                                     

annofabcli/annotation_specs/list_annotation_import_info.py

  • Langget_message_with_langをインポート追加
  • モデルに*_name_jaフィールド追加(label, attribute, choice)
  • 日本語名取得ロジックを実装
  • +11/-1   
    Tests
    test_list_annotation_import_info.py
    テストに日本語名検証を追加                                                                                       

    tests/annotation_specs/test_list_annotation_import_info.py

    • 日本語名フィールドのアサーション追加 (label_name_ja)
    • 属性・選択肢の日本語名検証を追加
    +4/-0     
    Documentation
    list_annotation_import_info.rst
    ドキュメントに日本語名説明と例追加                                                                               

    docs/command_reference/annotation_specs/list_annotation_import_info.rst

  • 説明文に日本語名項目を追加
  • JSONサンプルにlabel_name_ja,attribute_name_ja,choice_name_jaを追加
  • +12/-3   

    Need help?
  • Type /help how to ... in the comments thread for any questions about PR-Agent usage.
  • Check out the documentation for more information.
  • @kci-pr-agent

    kci-pr-agent Bot commented Aug 2, 2026

    Copy link
    Copy Markdown
    Contributor

    PR Reviewer Guide 🔍

    Here are some key observations to aid the review process:

    ⏱️ Estimated effort to review: 2 🔵🔵⚪⚪⚪
    🧪 PR contains tests
    🔒 No security concerns identified
    ⚡ Recommended focus areas for review

    翻訳フォールバック処理

    日本語名が存在しない場合のフォールバック動作を明示的に検証・ドキュメント化していますか。get_message_with_lang が想定通り英語名を返すことをテストやコードコメントで担保しましょう。

        choice_name_ja=get_message_with_lang(choice["name"], Lang.JA_JP),
    )
    for choice in attribute["choices"]
    テストカバレッジ不足

    実際の日本語翻訳(例:"car"→"車")がテストで検証されていません。翻訳データを含むケースを追加して、言語切替の正当性を担保しましょう。

    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"]
    
    type_attribute = next(e for e in car_label.attributes if e.attribute_name_en == "type")
    assert type_attribute.attribute_type == "select"
    assert [e.choice_name_en for e in type_attribute.choices] == ["large", "medium", "small"]
    assert [e.choice_name_ja for e in type_attribute.choices] == ["large", "medium", "small"]

    @yuji38kwmt yuji38kwmt changed the title feat: 日本語名を追加し、インポート情報の出力を強化 annotation_specs list_annotation_import_info: 出力する情報に日本語名も含める Aug 2, 2026
    result.append(
    AnnotationImportAttribute(
    attribute_name_en=get_attribute_name_en(attribute),
    attribute_name_ja=get_message_with_lang(attribute["name"], Lang.JA_JP),

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: 属性の日本語名が存在しない場合に英語名に戻るよう、or get_attribute_name_en(attribute)を追加してください。 [general, importance: 5]

    Suggested change
    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),

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    Suggestion: 選択肢の日本語名が取得できない場合に備えて、or get_choice_name_en(choice)による英語フォールバックを追加してください。 [general, importance: 5]

    Suggested change
    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),

    @yuji38kwmt
    yuji38kwmt merged commit 269f2cd into main Aug 2, 2026
    5 checks passed
    @yuji38kwmt
    yuji38kwmt deleted the 20260802 branch August 2, 2026 08:01

    Copilot AI left a comment

    Copy link
    Copy Markdown
    Contributor

    Choose a reason for hiding this comment

    The reason will be displayed to describe this comment to others. Learn more.

    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_langlang をキーワード専用にしている場合に実行時エラーになるので、ここも 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"
    

    Comment on lines 17 to +21
    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"]
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Labels

    None yet

    Projects

    None yet

    Development

    Successfully merging this pull request may close these issues.

    2 participants