Skip to main content

Excel形式のアノテーションファイルを扱うライブラリ

Project description

excelAno

Excel形式のアノテーションファイルを扱うライブラリ

excelAno は,Excel形式のアノテーションファイルを効率的に扱うためのPythonライブラリです.

アノテーターが使い慣れたExcelとエンジニア,研究者が使いやすいCSVの間の変換を行います.

主な機能

  • アノテーションファイルの読み込み: Excel形式のアノテーションファイルを読み込む.
  • バリデーション: 列名,データ型,必須項目,許容されるラベル値(例: ['Positive', 'Negative'])を事前に定義し,入力ミスを自動検知.
  • スムーズなフォーマット変換: 読み込んだデータをCSV としてエクスポート可能.
  • 評価結果の一致度評価: アノテーションの一致度を表す,kappa係数を計算可能.
  • テンプレート作成: 作業者向けに,ドロップダウンリスト(入力規則)などを設定した空のアノテーション用Excelをプログラムから生成.

インストール

pip install excelano

使用例

完全なコードは examples/ ディレクトリを参照してください.

1. アノテーション用テンプレートを作成する

アノテーターに配布するExcelテンプレートを,CSVデータから生成します. ドロップダウンリストやシート保護が自動設定されるため,入力ミスを防げます.

完全なコード: examples/01_create_template.py

from excelano.schema import Column, Schema
from excelano.template import Template

# スキーマを定義:各列の型や許容値を指定
schema = Schema(
    columns=[
        Column(name="id", dtype=int),
        Column(name="text", dtype=str),
        Column(name="label", dtype=str, allowed_values=["positive", "negative", "neutral"]),
    ],
    id_cols=["id"],
    annotation_cols=["label"],
)

# CSVからテンプレートを作成
template = Template.from_csv(
    file_path="data.csv",
    id_cols=["id"],
    annotation_cols=["label"],
    schema=schema,
)

# Excelに出力(ドロップダウン・シート保護・書式が自動設定される)
template.to_excel("annotation_template.xlsx")

2. アノテーション結果を読み込み・検証する

アノテーターが記入したExcelファイルを読み込みます. スキーマを指定すると,欠損値や不正な値がある場合にエラーが発生します.

完全なコード: examples/02_load_and_validate.py

from excelano.annotation_data import AnnotationData
from excelano.schema import Column, Schema

schema = Schema(
    columns=[
        Column(name="id", dtype=int),
        Column(name="text", dtype=str),
        Column(name="label", dtype=str, allowed_values=["positive", "negative", "neutral"]),
    ],
    id_cols=["id"],
    annotation_cols=["label"],
)

data = AnnotationData.from_excel(
    file_path="annotated.xlsx",
    annotated_cols=["label"],
    id_cols=["id"],
    schema=schema,
)

# pandas DataFrameとして操作可能
print(data.head())
data.to_csv("annotated.csv", index=False)

3. アノテーターの一致度を評価する(kappa係数)

複数のアノテーターの結果を比較し,評価の一致度をkappa係数で測定します. 2人の場合はCohen's kappa,3人以上の場合はFleiss' kappaが自動的に選択されます.

完全なコード: examples/03_compute_kappa.py

from excelano.annotation_data import AnnotationData, MultipleAnnotationData

# 各アノテーターのデータを読み込み
annotator_a = AnnotationData.from_excel(
    "annotator_a.xlsx", annotated_cols=["label"], id_cols=["id"]
)
annotator_b = AnnotationData.from_excel(
    "annotator_b.xlsx", annotated_cols=["label"], id_cols=["id"]
)

# 一致度を計算(2人 → Cohen's kappa)
multi = MultipleAnnotationData([annotator_a, annotator_b])
kappa = multi.compute_kappa("label")
print(f"Cohen's kappa: {kappa:.3f}")

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

excelano-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

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

excelano-0.1.0-py3-none-any.whl (13.1 kB view details)

Uploaded Python 3

File details

Details for the file excelano-0.1.0.tar.gz.

File metadata

  • Download URL: excelano-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for excelano-0.1.0.tar.gz
Algorithm Hash digest
SHA256 8effeb9625f50f59210a160dcc5614896b492697686136b17a52cbc7b8cdedc3
MD5 c58fd51f834a754bf299d9e308018b25
BLAKE2b-256 7825bc555c71172f5205ef4f978344531bb0aee3ca300f76714ff9766e2a3180

See more details on using hashes here.

File details

Details for the file excelano-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: excelano-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.22

File hashes

Hashes for excelano-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e09ca2da48963536ec7c1f653d371ed52b4a1e3b2249bb0f0b9701eefbedcbfc
MD5 82fc5033f6f69c5b492c7a1bb43ac51d
BLAKE2b-256 5e7afc39778df58bd070ad187af246c94182ad561de7ae2e3ef22a748bfc7bc7

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