安装配置使用brat文本标注工具

brat 标注工具是基于unix-like 和 webserver的,且要求python2.5以上的环境

brat 的下载地址 http://brat.nlplab.org/ 

官网安装步骤:http://brat.nlplab.org/installation.html#quick_start_installation_using_cgi

Ubuntu16.04安装CGI环境:

1. 安装Apache2:

sudo apt install apache2

2. 配置CGI

1)打开文件/etc/apache2/sites-enabled/000-default.conf

sudo gedit /etc/apache2/sites-enabled/000-default.conf

找到以下的内容:
#Include conf-available/serve-cgi-bin.conf

修改为 Include conf-available/serve-cgi-bin.conf (去掉注释) ,该配置文件的修改需要root权限

2)打开文件/etc/apache2/conf-available/serve-cgi-bin.conf

sudo gedit /etc/apache2/conf-available/serve-cgi-bin.conf

找打以下的内容:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Require all granted
</Directory>
修改为:

ScriptAlias /cgi-bin/ /var/www/html/cgi-bin/
<Directory "/var/www/html/cgi-bin/">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Require all granted
    AddHandler cgi-script cgi
</Directory>

该配置文件的修改需要root权限

3) 打开文件/etc/apache2/mods-available/cgid.load,

sudo gedit /etc/apache2/mods-available/cgid.load

在LoadModule cgid_module /usr/lib/apache2/modules/mod_cgid.so下加上:
AddHandler cgi-script .cgi .pl .py .sh

4) 链接文件:

sudo ln -s /etc/apache2/mods-available/cgid.load /etc/apache2/mods-enabled/cgid.load

5)重启Apache2,终端输入:

sudo /etc/init.d/apache2 restart

6) 新建/cgi-bin文件夹,终端输入:

sudo mkdir /var/www/html/cgi-bin/

7) 创建一个CGI文件

在/var/www/html/cgi-bin/下新建helloworld.c文件(需root权限)

sudo touch /var/www/html/cgi-bin/helloworld.c
sudo vim /var/www/html/cgi-bin/helloworld.c

文件中的内容:

#include <stdio.h>
int main()
{
        printf("Content-Type: text/html\n\n");
        printf("Hello World!\n");
        return 0;
}

编译源文件: 

sudo gcc /var/www/html/cgi-bin/helloworld.c -o /var/www/html/cgi-bin/helloworld.cgi

修改CGI文件权限:

sudo chmod 755 /var/www/html/cgi-bin/helloworld.cgi

测试
浏览器键入:http://localhost/cgi-bin/helloworld.cgi,在页面可以看到 Hello World!

以上配置CGI 参考: https://blog.csdn.net/prince1394/article/details/80295098

安装Brat标注工具:

1. 下载好的brat安装包,解压

tar -zxvf brat-v1.3_Crunchy_Frog.tar.gz

2. 由于已经配置过CGI保证系统服务器可用,则可以直接安装

cd /brat-v1.3_Crunchy_Frog/
sudo install.sh

安装的过程中要求设置用户名,密码,邮箱 出现 The installation has finished, you are almost done. 及后续的提示则安装成功

3. 启动服务器

python standalone.py

出现服务器的url是http://127.0.0.1:8001

4. 访问url, 界面如下:

5. 支持中文:
brat本身是不支持中文的,如果在配置文件里定义中文会报错,解决办法是修改./server/src/projectconfig.py文件的第163行,加上中文支持即可: 

将英文的这句话注释掉,并添加如下内容:

n = re.sub(u'[^a-zA-Z\u4e00-\u9fa5<>,0-9_-]', '_', n)

6. 使用:

解锁文件夹:

sudo chown username 文件夹路径 -R 

data 文件夹下创建自己的数据文件夹  eg: data/project/aa

aa中放入数据集 ‘xxx.txt’和同名的xxx.ann

创建xxx.ann的方法:

sudo find 文件夹路径 -name 'data.txt' | sed -e 's|\.txt|.ann|g' | xargs touch

相关配置文件也要放入其中

未完待续.......
 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值