Table Of Contents

Previous topic

Use SVM Perf

Next topic

Use TinySVM

This Page

Use CRF++

This page describes a procedure that enables CRF++ to be used with RaSC. CRF++ must be changed at the program level to perform input and output through file (for the changes, refer to How can I modify existing user programs to run them on RaSC?).

The following describes a procedure to change the program by applying a patch to it so that CRF++ may be used as an RaSC service.

Change CRF++ to be RaSC-enabled

First, get the CRF++ source code.

$ wget http://crfpp.googlecode.com/files/CRF%2B%2B-0.57.tar.gz
$ tar zxvf CRF++-0.57.tar.gz

Then, get the patch file.

$ wget https://alaginrc.nict.go.jp/rasc/resources/patch_rasc_crf.diff

Then, apply the patch.

$ patch -p0 < patch_rasc_crf.diff

Then, build CRF++.

$ cd CRF++-0.57
$ ./configure
$ make

These commands produce the executable binary crf_test, which has been modified so that it can be used with RaSC.

Configure service XML for CRF++

In a service definition XML, describe a start command line that includes the path to and the model file of the executable binary (you can download the service XML).Modify ___BASE_DIR___ and ___PATH_TO_MODEL_FILE___ to the directory that actually includes crf_test and the path to the model file.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
  <bean id="target"
    class="jp.go.nict.langrid.servicecontainer.handler.TargetServiceFactory">
    <property name="service">
      <bean class="jp.go.nict.wisdom.wrapper.StdIOCommandService">
        <property name="cmdLine" value="___BASE_DIR___/crf_test -m ___PATH_TO_MODEL_FILE___ -" />
        <property name="delimiterIn" value="\n[END_OF_INPUT]\n" />
        <property name="delimiterOut" value="EOS\n" />
        <property name="delLastNewline" value="true" />
      </bean>
    </property>
  </bean>
</beans>
  • For cmdLine, specify the path to and the model file for CRF that was created before by applying the patch. The last - means an option to accept the input data from standard input.
  • For delimiterIn, describe \n[END_OF_INPUT]\n because the patch has been applied to set the input delimiting character string to [END_OF_INPUT].
  • Similarly, for delimiterOut, describe EOS\n because the patch has been applied to set the output delimiting character string to EOS\n.
  • Within the program, \n in this example will be replaced with an appropriate linefeed code suitable for each system.

For information on the procedure to start the service, refer to Run a user program as a RaSC service or Work with various network protocols