保姆级brat标注工具部署,在弄崩了好几个虚拟机之后终于弄好了,毕竟菜鸡。。。
1.下载brat
进入brat官网下载安装包brat-v1.3_Crunchy_Frog.tar.gz 。
在/home/你的用户名目录下新建文件夹命名为public_html,并将brat安装包解压缩到该文件夹。
进入brat-v1.3_Crunchy_Frog文件夹开始安装
bash install.sh
之后输入账号密码及邮箱
进入brat-v1.3_Crunchy_Frog/server/lib文件夹,解压缩flup-1.0.2.tar.gz
2.安装python2
brat运行需要python2,如果已安装则忽略
sudo apt install python
这里可能会提示以下错误
The following packages have unmet dependencies: python : PreDepends: python-minimal (= 2.7.15~rc1-1) but it is not going to be installed Depends: python2.7 (>= 2.7.15~rc1-1~) but it is not going to be installed E: Unable to correct problems, you have held broken packages.输入以下命令解决,之后重新执行安装python的命令即可
sudo apt purge libpython2* sudo apt install python
3.安装Apache并配置
sudo apt-get install apache2
配置Apache的配置文件
sudo vim /etc/apache2/apache2.conf
Ubuntu18.04默认安装vi,可以把上面命令的vim改成vi,如果想使用vim,执行以下命令删除vi安装vim
sudo apt-get purge vim-common sudo apt-get update sudo apt-get upgrade sudo apt-get install vim
进入apache2.conf文件后,将以下内容填入并保存
<Directory /home/你的用户名/public_html>
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>
# For FastCGI, Single user installs should be fine with anything over 8
#FastCgiConfig -maxProcesses 16
给suerdir赋权
sudo a2enmod userdir
输出提示信息如下:
Enabling module userdir. To activate the new configuration, you need to run: systemctl restart apache2
安装libapache2-mod-fastcgi
sudo apt-get install libapache2-mod-fastcgi
这一步可能会提示:
正在读取软件包列表... 完成 正在分析软件包的依赖关系树 正在读取状态信息... 完成 没有可用的软件包 libapache2-mod-fastcgi,但是它被其它的软件包引用了。 这可能意味着这个缺失的软件包可能已被废弃, 或者只能在其他发布源中找到 E: 软件包 libapache2-mod-fastcgi 没有可安装候选解决办法:
打开
sources.listsudo vim /etc/apt/sources.list在文件末添加
deb http://mirrors.digitalocean.com/ubuntu trusty main multiverse deb http://mirrors.digitalocean.com/ubuntu trusty-updates main multiverse deb http://security.ubuntu.com/ubuntu trusty-security main multiverse保存后执行
sudo apt-get update再次执行安装命令即可安装
继续输入以下命令
sudo a2enmod fastcgi
sudo a2enmod rewrite
输出提示信息如下:
Module fastcgi already enabledEnabling module rewrite. To activate the new configuration, you need to run: systemctl restart apache2
重新加载apache的配置:
sudo /etc/init.d/apache2 reload
进入到/home/你的用户名/public_html/brat-v1.3_Crunchy_Frog文件夹,然后执行:
sudo chgrp -R www-data data work
chmod -R g+rwx data work
安装standalone server
bash install.sh -u
然后运行服务
python standalone.py
之后便可以从你的ip地址+8001端口访问brat
4.使用
中文支持,在brat-v1.3_Crunchy_Frog/server/src目录下找到projectconfig.py文件,在162行可以看到
n = re.sub(r'[^a-zA-Z0-9_-]', '_', n)
将其注释掉,并添加
n = re.sub(u'[^a-zA-Z\u4e00-\u9fa5<>,0-9_-]', '_', n)
添加标注文本,在brat-v1.3_Crunchy_Frog/data文件夹下添加标注的文本,然后在brat-v1.3_Crunchy_Frog目录下执行以下命令就会生成和标注文本文件名相同文件后缀为.ann的文件,这个文件保存了标注结果。
find data -name '*.txt' | sed -e 's|\.txt|.ann|g' | xargs touch
brat支持标注[entities][relations][events][attributes],把brat-v1.3_Crunchy_Frog目录下annotation.conf中对应的地方改成你要标注的即可,如果想要在标注页面显示成中文,则需要修改相同目录下的visual.conf,具体如何修改打开文件就明白了。

本文详细介绍了一种名为brat的文本标注工具的部署过程,包括下载安装包、配置Apache服务器、安装Python2及libapache2-mod-fastcgi等步骤,同时提供了中文支持的配置方法。
1759

被折叠的 条评论
为什么被折叠?



