星光尽头

科技与人文的那个交集

M.J

All posts tagged “CQPweb”

CQPweb使用cqpweb-autoconfig.php自动配置

cqpweb-autoconfig.php是CQPweb提供的一个自动化配置脚本,方便对CQPweb运行所需要的参数进行配置。本文将我的配置流程记录下来并做笔记,以便有需要的朋友参考,如有什么问题,请在下面留言与我交流。

先说下我的用户配置,我为CQPweb专门创建了一个用户,名为CQPweb,从属apache运行用户www-data组,CQPweb相关的所有数据都放到/home/CQPweb下,主要分为CWB3,CQPweb,perl和Data四个目录。

开始运行:切换到相应目录(我的为/home/CQPweb/CQPweb)下,运行php cqpweb-autoconfig.php,以下为交互内容,蓝色为自己输入部分,绿色部分为注释,黑字部分为系统输出。

/***********************/
This is the interactive configuration setup program for CQPweb.

Are you using the Apache web server?                           // 是否在使用apache网页服务器

Enter [Y]es or [N]:y
OK, we’ll create .htaccess, .htpasswd, and .htgroup files.

Please enter
the username you want to use for the sysadmin account.
Note this can only contain ASCII letters, numbers and underscore.  //你想给系统管理员账户使用的用户名,只能包含ascii字符,数字和下划线

youradmin

Add another admin username?) [y/n]               //是否继续添加管理员用户,一般一个够了,搭建好后可以在后台修改

n
Please enter
the path to the directory containing the cwb executables
as an absolute directory path:

/home/CQPweb/CWB3/bin
Please enter
the path to the directory containing the apache passwd utilities
as an absolute directory path:
/usr/bin
Please enter
the path to the directory containing the perl executable   //包含perl可执行程序的路径
as an absolute directory path:

/usr/bin

Please enter
the path to the directory you wish to use for the CWB datafiles
as an absolute directory path:

/home/CQPweb/Data/CWBData
Please enter
the path to the directory you wish to use for CWB registry files
as an absolute directory path:

/home/CQPweb/Data/CWBReg
Please enter
the path to the directory you wish to use for the CQPweb cache and other temp files
as an absolute directory path:

/home/CQPweb/Data/CQPCache
Please enter
the path to the directory you wish to store passwords / group files in
as an absolute directory path:

/home/CQPweb/Data/CQPAuth
Please enter
the path to the directory you wish to store uploaded files in
as an absolute directory path:

/home/CQPweb/Data/Upload
Please enter
the MySQL username that you want CQPweb to use (do NOT use root).
Note this can only contain ASCII letters, numbers and underscore.

CQPweb
Please enter
the password for this MySQL user.
Note this can only contain ASCII letters, numbers and underscore.

yourpasswd
Please enter
the name of the MySQL database to use for CQPweb tables.
Note this can only contain ASCII letters, numbers and underscore.

CQPweb

Note: the system will be set to use ‘localhost’ as the MySQL server.
If you want to use a different MySQL server, please edit config.inc.php manually.

Saving config file …

Creating admin username(s) in Apache htpasswd/htgroup files…

(NB: admin passwords will be the same as the username
you should reset them as soon as possible)

Adding password for user starit
The files have been created within user group www-data.

The members of this group are:

If the username that the Apache httpd server runs under is not a member
of this group, CQPweb will not be able to modify the htpasswd/htgroup files
(which it needs to be able to do).

Do you want to keep this group for the htpasswd/group files?

Enter [Y]es or [N]:y
OK – onwards!
Done! note that the source file for this script will be gzipped,
to avoid unwanted re-running.

You should delete this program (or move it out of the web directory) for security.

CQPweb语料库搭建教程

大四的时候接受过老师一个任务,使用CQPweb搭建一个语料库并对其进行易用性改进。因为彼时还要忙于考研,所以并没有花太多时间在上面,CQPweb虽然搭建起来了,进行了简单的开发,但并没有持续做下去,此事老师也没再提,后来不了了之。但因为国内还没有很多CQPweb的资料,连官网都要翻墙才能上去,所以那时想写一个中文版的教程来介绍一下CQPweb,并给出一些安装和使用的心得。

我搭建的CQPweb:www.star404.com:8080,目前还没有什么语料库,这两天我会抽时间把能找到的语料库放上去。

文章基于官方资料和自己的理解写成,若有错误,请不吝指正。
一.CQPweb概述
1.CPQweb介绍
CQPweb是由英国兰卡斯特大学一名教授开发的基于CWB的第四代语料库分析工具,免费开源。CQPweb的主要特点是:
1、将语料库与分析工具合二为一;
2、支持多语种语料库的分析;
3、运用了索引技术,检索速度大大快于单机版语料库;
4、充分利用语料库的元信息,提供更多呈现语料分析结果的呈现方式。(1)
2.国内外相关应用
因为本人不是语言学的专业人士,关于语料库的应用以及利用语料库进行研究的方法请自行寻找资料,本文不作叙述。(技术上只需要把语料库理解为一种特殊的数据库即可。)
北京外国语大学的许家金副教授曾利用CPQweb搭建了北外的“BFSU CQPweb多语言在线语料库检索平台”(地址http://124.193.83.252/cqp/ ,用户名:test,密码:test)。国内大部分中文资料亦来源于他。
3.相关的网站及资源:
项目网站:http://cwb.sourceforge.net(需要翻Wall)
兰卡斯特大学CQPweb: https://cqpweb.lancs.ac.uk
BFSU CQPweb(北外): http://124.193.83.252/cqp/
二.安装
1.组成
CQPweb语料库由三个部分组成,CWB(The IMS Corpus Workbench ),Perl API,CQPweb。其中CWB是语料库, Perl API是CWB提供的接口,CQPweb则是基于Web的图形界面和分析工具。
前文所说的CQPweb语料库是方便称呼,事实上CQPweb并不包含语料库本身。但为了方便还是约定一下,在本文中提到的CQPweb语料库是指整个语料库系统,包含CWB,Perl API,CQPweb三者,而CQPweb则是单指基于CWB的图形化界面的分析工具。
2.安装环境
CWB支持Windows,Mac OS X,Linux等多种平台,但CQPweb暂时只支持Linux,所以本文不讨论其他平台的使用。
安装CWB-3.0需要以下软件支持autoconf bison flex gcc libc6-dev libncurses5-dev make,在ubuntu下可运行
apt-get install autoconf bison flex gcc libc6-dev libncurses5-dev make
一般的Linux都能安装运行CQPweb语料库,运行CQPweb需要在Linux下安装好以下组件:Apache,MySQL,PHP,Perl。
到官网链接上直接下好CQPweb语料库安装所需要文件,若不方便也可以到sourceforge下载最新版的CWB和API PERL,地址为http://sourceforge.net/projects/cwb/files/?source=navbar。
3.下载所需软件
有多种方式下载所需的软件,这里推荐使用svn的方式下载,下面下载地址引用自官网。注意export后要将3.0重新命名,否则可能会将cwb-3.0和cqpweb放到同一个目录中。
如果不想用svn或者地址打不开,可以下载我整理的压缩包,包含安装所需要的所有软件。
  • svn export http://svn.code.sf.net/p/cwb/code/cwb/branches/3.0 cwb-3.0 (IMS Open Corpus Workbench)
  • svn export http://svn.code.sf.net/p/cwb/code/perl/trunk/CWB Perl-CWB-3.0 (Perl CWB package)
  • svn export http://svn.code.sf.net/p/cwb/code/perl/branches/3.0/CWB-CL Perl-CWB-CL-3.0 (Perl CWB-CL package)
  • svn export http://svn.code.sf.net/p/cwb/code/perl/trunk/CWB-Web Perl-CWB-Web-3.0 (Perl CWB-Web package)
  • svn export http://svn.code.sf.net/p/cwb/code/perl/trunk/CWB-CQI Perl-CWB-CQI-3.0 (CQi reference implementation)
  • svn export http://svn.code.sf.net/p/cwb/code/gui/cqpweb/branches/3.0 CQPweb (CQPweb GUI) (stable version)
 
下载完成后将会得到6个文件夹。
    我的百度云分享:http://pan.baidu.com/s/1nt7MyhV
4.安装CWB
先进入CWB-3.0所在的文件夹中,编辑config.mk, 修改参数,修改平台,PREFIX为想要的安装目录,默认为/usr/local
5.安装Perl API
6.安装CQPweb
=======
在CQPweb文件夹下有一个CQPweb-setup-manual.html的文件,用浏览器打开阅读安装说明,如果您英文足够好,建议直接参考该文档进行操作,以下操作只摘取重要的部分。
首先需要对PHP进行设置。
——–
  • 因为需要上传语料库文件,所以推荐将php.ini中的upload_max_filesize设置为20M。
  • post_max_size需要至少和upload_max_filesize一样高。
  •  memory_limit适量地调高,因为CQPweb有些操作是内存密集的(比如将一些实体文件载入到内存中);建议为25M,但是如果你的系统默认设置要更高,请保留更高的设置。
  • max_execution_time应该尽可能地调高,建议为60

如果PHP的版本是Suhosin的,则需要增加一行

  • suhosin.get.max_value_length = 8000

最后,PHP最好不要激活安全模式(safe-mode)的配置,否则你会发现一些CQPweb操作无法工作。

设置网页服务器,默认使用Apache。
——–
需要设置.htaccess能够在CQPweb的目录起作用,即需要设置CQPweb所在目录AllowOverride All,具体操作方法请搜索apache的配置方法。
设置Perl
———
  暂略
设置MySQL
——-
  • 你需要创建一个新的用户和一个新的数据库来给CQPweb使用。
  • 新的数据库应该以UTF-8为默认编码,新用户则需要这个新数据库的所有权限。
  • 如果需要启用MySQL的文件访问功能(非必需,但能加速),新用户需要有全局的file权限,即grant file on *.* …
创建目录
——-
CQPweb本身源码需要放在一个apache配置文件中指定的web目录下面,默认情况下/var/www是web目录,这样只需要放到/var/www/CQPweb下就行了。
CQPweb工作时需要额外创建几个目录,分别用于存放CQPweb的用户名和密码文件,临时文件,索引后的语料库,索引后语料库的注册文件,上传文件区域,总共五个文件夹。运行apache的用户,如_www需要能对所有这些目录都有可读可写可执行的权限。
记下这几个目录的路径,以后会用到。
创建配置文件
——
到CQPweb的源码目录下,使用php cqpweb-autoconfig.php来自动配置CQPweb。
配置的详细操作请见我的这篇博客http://www.star404.com/2014/12/how-to-run-cqpweb-autoconfig-php。
初始化操作(包括生成数据库)
——
假设CQPweb所对应的网址是localhost/CQPweb,则进入localhost/CQPweb/adm。如果一切正常,会弹出一个对话框让你输入帐号与密码。输入刚才设置的帐号,密码与帐号相同。确认进入后台。此时后台界面如图1.1所示。
CQPweb settings1
(图1.1 CQPweb后台管理界面)
完成以下初始化操作:
1.点击Reset MySQL Database,并且完成操作。
2.点击“manage users”,为superusers设置安全的密码。
3.点击“System security”,然后点击”restore default security”(只有在Apache Web服务器下)
4.点击“Skins and colours”,然后点击“Regenerate colour schemes”
5.点击“Mapping tables”,然后点击Regenerate built-in mapping tables”
CQPweb settings 2
(图1.2 MySQL成功重建数据)
如果您成功完成了以上操作,请进入打开CQPweb对应的网址,如localhost/CQPweb查看是否有报错信息,如果一切正常,那么恭喜您,CQPweb已经初步安装成功。此时应该如图1.3所示:
CQPweb normal UI
(图1.3 CQPweb初始正常界面)
后续只需要将语料库加上去好,则界面会逐渐丰富起来。
参考资料
[1] 参考网上资料
========================================
星魂版权所有
转载请注明作者
个人网站:http://www.star404.com
个人微博:http://www.weibo.com/stariit/
回到顶部