Potato(土豆)一款轻量级的开源文本标注工具(一)

项目介绍:

Potato 是一款轻量级、可移植的Web文本标注工具,被EMNLP 2022 DEMO赛道接受。它旨在帮助用户快速地从零开始创建和部署各种文本标注任务,无需复杂的编程或网页设计。只需简单配置,团队即可在几分钟内启动并运行标注项目。

注: EMNLP是计算语言学和自然语言处理领域顶级国际会议之一,与ACLNAACLCOLING并称为自然语言处理与计算语言学领域的四大顶级会议。

Potato允许您快速模拟和部署各种文本注释任务。Potato在后端作为web服务器工作,在本地部署安装启动它,就可以基于web的前端来标注数据。Potato工具的目标是允许人们自己或小团队快速轻松地注释文本数据——只需几行配置即可从零开始做标注任务。

Potato 依赖于一个配置文件驱动,定义了任务类型和所需的数据。通过这个配置文件,你可以设置不同的标注模式,如单选、多选、文本框、跨度、配对比较等,支持不同数据类型,包括短文、长文、对话和比较。

Potato不需要任何编码即可启动和运行。对于大多数任务,不需要额外的web设计。Potato很容易自定义,可以调整注释器看到的界面和元素。

有关详细说明,可以查看官方文档

安装运行:

安装 Potato 并启动样例项目,官方提供了两种方式:

方式1:直接使用pip安装包( potato-annotation · PyPI

pip install potato-annotation
potato get sentiment_analysis
potato start sentiment_analysis

方式2:从git仓库下载源码安装(GitHub - davidjurgens/potato: potato: portable text annotation tool

git clone https://github.com/davidjurgens/potato.git

cd potato

pip install -r requirements.txt

# 启动实例(一种简单的多选框标注方式)
python potato/flask_server.py start project-hub/simple_examples/configs/simple-check-box.yaml -p 8000

运行完后,访问 [http://localhost:8000] 即可体验。

我的实验:在windows环境下安装,第一种方式有报错,暂时没有去解决,就直接按第二种方式安装运行了。。

实验应用

简单采用项目中提供的simple-check-box(多选框)实例,后台启动运行后,就可以直接在本地浏览器打开运行 [http://localhost:8000] 。

初次登录时需要注册一下(注册信息存在本地,应该是相同任务作业,区分不同用户使用)

在potato项目的实例目录potato\project-hub\simple_examples下面,有三个文件夹:

其中,data中存放的待标注的样本文件, 其中文本文件有json,csv和tsv三种格式。

configs中不同标注风格的配置实例,比如,我们这次运行的simple-check-box.yaml

annotation_output存放是标注结果的输出文件,可以在配置时,指定是tsv, csv 或 json格式。

在配置文件simple-check-box.yaml中,原本的输入样本文件是data/toy-example.csv。假设我们需要修改为自己的标注文件test1.csv,只需要更改配置文件的输入文件行,参考如下:

{
    "port": 9001,

    "server_name": "potato annotator",

    "annotation_task_name": "Simple Check Box Example",

    # Potato will write the annotation file for all annotations to this
    # directory, as well as per-annotator output files and state information
    # necessary to restart annotation.
    "output_annotation_dir": "annotation_output/simple-check-box/",

    # The output format for the all-annotator data. Allowed formats are:
    # * jsonl
    # * json (same output as jsonl)
    # * csv
    # * tsv
    #
    "output_annotation_format": "tsv", 

    # If annotators are using a codebook, this will be linked at the top to the
    # instance for easy access
    "annotation_codebook_url": "",

    #"data/toy-example.csv"
    "data_files": [
       "data/test1.csv"
    ],

    "item_properties": {
        "id_key": "id",
        "text_key": "text",
        "context_key": "context"
    },


    "user_config": {

      "allow_all_users": True,
      
      "users": [  ],
    },

    # How many seconds do you want the annotators spend on each instance, after
    # that, an alert will be sent per alert_time_each_instance seconds.
    "alert_time_each_instance": 10000000,

    "annotation_schemes": [      
        {
            "annotation_type": "multiselect",
            "name": "favorite_color", 
            "description": "What colors are mentioned in the text?",
            "labels": [
               "blue", "maize", "green", "white"
            ],

            # If true, numbers [1-len(labels)] will be bound to each
            # label. Check box annotations with more than 10 are not supported
            # with this simple keybinding and will need to use the full item
            # specification to bind all labels to keys.
            "sequential_key_binding": True,            
        },       
    ],

    # The html that changes the visualiztation for your task. Change this file
    # to influence the layout and description of your task. This is not a full
    # HTML page, just the piece that does lays out your task's pieces
    # you may use templates in our lib, if you want to use your own template,
    # please replace the string as a path to the template
    "html_layout": "default",

    # The core UI files for Potato. You should not need to change these normally.
    #
    # Exceptions to this might include:
    # 1) You want to add custom CSS/fonts to style your task
    # 2) Your layout requires additional JS/assets to render
    # 3) You want to support additional keybinding magic
    #
    # if you want to use your own template,
    # please replace the string as a path to the template
    "base_html_template": "default",
    "header_file": "default",

    # This is where the actual HTML files will be generated
    "site_dir": "default"

}

仿造式例中"data/toy-example.csv"文件, 新的test1.csv文件的字段需要用英文逗号分隔。

id,text
item_1,它的一些方式。
item_2,他们不会感到疼痛。
item_3,它不会自行处理。
item_4,四个人想请一些志愿者来增加时间。
item_5,请求不是quiquia。
item_6,因为他的帮助,他快五十岁了。
item_7,为任何人考虑痛苦。
item_8,时间不会伤害你。
item_9,一美元的开心果很好,而且不会受伤。
item_10,委员会。
item_11,因为没有人想做自己。

最后,打开web端的标注页,展示效果如下:

总结:使用potato标注工具,按照提供的式例文件(覆盖了常见的自然语言的标注任务),通过简单修改配置文件(yaml格式), 就可以开展独立的标注任务,同时也可以修改配置文件,简单改变页面展示效果(如英文界面替换成中文的)。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值