The server encountered a serious error, please contact the administrators at ____ and give the id#
记录安装brat时遇到的坑
使用brat进行事件标注时,因为需要中文,所以使用了:
# n = re.sub(r'[^a-zA-Z0-9_-]', '_', n)
n = re.sub(u'[^a-zA-Z\u4e00-\u9fa5<>,0-9_-]', '_', n)
但是在中文触发词连接到论元时,会报错,无法进行角色的设置。brat底部界面显示The server encountered a serious error, please contact the administrators at ____ and give the id#
查看apache2的报错日志
我是在ubuntu上安装的brat,(之前在centos上同样遇到这个问题,当时没有解决),在 /var/log/apache2/error_log 中查看具体的错误,错误如下:
然后简单查看了报错信息在/server/src/server.py和/server/src/annotation.py这两个文件中的位置,以及在网上搜索了**UnicodeEncodeError: ‘ascii’ …**这个错误原因。
我的解决方法
我最后在/server/src/server.py这个文件中加了下面代码:
import sys
reload(sys)
sys.setdefaultencoding('utf8')
至此,可以正常运行,并解决中文触发词无法连接论元的问题。