目录
1. !!! Docker 镜像 !!!
2. Brat 是什么?
3. Brat 安装、部署前,你需要知道的一些事情..
4. 安装 python
5. 安装 Apache httpd
6. 安装 Brat
7. 使用 Brat
本文描述了
在 CentOS 8 中的安装、部署 Brat 的全过程
1. !!! Docker 镜像 !!!
为了方便大家使用
我把下面的整个安装、部署过程搞成了一个 Docker 镜像
是可以直接使用的哟
docker pull webj2eedev/brat-1.3
docker run -it \
-p 8080:80 \
-v e:\bratdata:/var/www/html/brat/data \
webj2eedev/brat-1.3:v1
http://localhost:8080/brat
docker run -it \
-p 8080:80 \
-v e:\bratdata:/var/www/html/brat/data \
-e username=admin1 \
-e password=sa1 \
-e email=admin1@sa1.com \
webj2eedev/brat-1.3:v1
2. Brat 是什么?
BRAT是一个基于web的文本标注工具,主要用于对文本的结构化标注。用BRAT生成的标注结果能够把无结构化的原始文本结构化,供计算机处理。利用该工具可以方便的获得各项NLP任务需要的标注语料。
brat is a webbased tool for text annotation; that is, for adding notes to existing text documents. brat is designed in particular for structured annotation, where the notes are not freeform text but have a fixed form that can be automatically processed and interpreted by a computer.
3. Brat 安装、部署前,你需要知道的一些事情..
The brat server is implemented in Python, and requires version 2.5 (or higher in the 2.x series) of python to run.
In its standard setup, brat is a served through a web server. If you are installing brat server on a machine that is not currently running a web server, you should consider starting by installing one. brat is currently developed against Apache 2.x, and we recommend using Apache.
4. 安装 python?
使用 CentOS 的默认包管理工具 dnf 安装 python2.
dnf install python2 -y
验证 python2 是否安装成功(注意这里使用 python2 命令)
python2 --version
设置 python2 为系统默认 python (PS: 我不想一直用 python2 命令访问 python)
whereis python2
alternatives --set python /usr/bin/python2
再验证一下 python 命令是否可用(注意这里是 python 命令,不是 python2 了)
python2 --version
5. 安装 Apache httpd
使用 CentOS 的默认包管理工具 dnf 安装 Apache httpd.
dnf install httpd -y
验证 httpd 是否安装正常
httpd -version
验证 httpd 是否服务正常(ps:httpd 托管的静态文件默认在 /var/www/html/ 目录中)
echo "<h1>Hello Webj2eedev</h1>" > /var/www/html/index.html
6. 安装 Brat
下载:去官网下载 Brat(好多年没更新了,一直是 1.3)
http://weaver.nlplab.org/~brat/releases/brat-v1.3_Crunchy_Frog.tar.gz
解压:将 Brat 解压到 /var/www/html/ 目录(apache httpd),并将默认目录名 brat-v1.3_Crunchy_Frog 修改为 brat(好记)
赋权:直接给 brat 目录 777 吧,省事
chmod -R 777 ./brat
安装:安装过程中会提示输入用户名、密码、邮箱信息。用户名和密码用于 web 浏览器用户登录。
./install.sh
配置(apache httpd):
/etc/httpd/conf/httpd.conf
<Directory /var/www/html/brat>
AllowOverride Options Indexes FileInfo Limit
AddType application/xhtml+xml .xhtml
AddType font/ttf .ttf
# For CGI support
AddHandler cgi-script .cgi
# Comment out the line above and uncomment the line below for FastCGI
#AddHandler fastcgi-script fcgi
</Directory>
配置(用户组):
chgrp -R apache data work
配置(Brat 支持中文):
/var/www/html/brat/server/src/projectconfig.py
n = re.sub(r'[^a-zA-Z0-9_-]', '_', n)
n = re.sub(u'[^a-zA-Z\u4e00-\u9fa5<>,0-9_-]', '_', n)
重启(apache httpd):
httpd -k restart
验证(http://ip:port/brat):
7. 使用 Brat
官方建议使用 Chrome、Safari 浏览器
标签定义、数据导入:
目录中包含:标签定义、待标注数据
[entities]
药品
成分
人群
[relations]
不适用 Arg1:药品,Arg2:人群
成分是 Arg1:药品,Arg2:成分
[attributes]
[events]
[labels]
药品 | 药品
成分 | 成分
人群 | 人群
不适用 | 不适应
成分是 | 成分是
[drawing]
药品 bgColor:green
成分 bgColor:blue
人群 bgColor:maroon
不适用 bgColor:maroon
成分是 bgColor:maroon
登录系统:
标注:
标注结果:
参考:
Brat: http://brat.nlplab.org/index.html http://brat.nlplab.org/supported-browsers.html