首先我们需要了解svmlight的工作方式,可以参见我的github中介绍:
网址:
这里就简单介绍一下:
- 我们首先要安装svmlight
mkdir svm_light
Download svm_light.tar.gz from svmlight.joachims.org and put it in your svm_light directory.
cd svm_light
gunzip -c svm_light.tar.gz | tar xvf -
make - 然后以官网上的例子为例介绍如何使用svmlight
我们首先还是要在官网上找到如下一段话,点击下载
Download example1.tar.gz from svmlight.joachims.org.
gunzip -c example1.tar.gz | tar xvf -
This will create a directory called example1 that contains the training examples (train.dat) and the test examples (test.dat). To learn a support vector classifier for the training examples and then use it to classify the test examples, do this:
之后呢按照如下操作进行:
./svm_learn example1/train.dat example1/model
./svm_classify example1/test.dat example1/model example1/predictions
得到的predictions文件就是我们想要的结果啦~ - 但是通过观察train.dat我们可以发现,他的格式似乎不是那么容易得到~
接下来以我实际的代码为例讲解一下如何生成这种格式
https://github.com/angelamin/Natural_Language_Processing/blob/master/Natural_Language_Processing_Lab_Task3/%E4%BB%BB%E5%8A%A1%E4%B8%89%E4%BB%8B%E7%BB%8D.rtf
以上链接是我的具体任务的介绍,简单介绍一下,我要实现将给定的语料,实现以B开头,I结尾,然后用svmlight来处理,得到以后测试文件对应汉字的B/I
然后就开始了我的格式处理之路,大家具体参考我的代码吧~
另外,关于所有处理程序的关键思想都写在introduce目录下
最后我给出这个项目的网址:
https://github.com/angelamin/Natural_Language_Processing/tree/master/Natural_Language_Processing_Lab_Task3
希望对大家有帮助~