public void train() throws Exception {
System.out.print("Loading training data ...");
long beginTime = System.currentTimeMillis();
Pipe pipe = createProcessor(false);
InstanceSet trainSet = new InstanceSet(pipe, factory);
LabelAlphabet labels = factory.DefaultLabelAlphabet();
IFeatureAlphabet features = factory.DefaultFeatureAlphabet();
// 训练集
trainSet.loadThruStagePipes(new SequenceReader(train,true, "utf8"));
long endTime = System.currentTimeMillis();
System.out.println(" done!");
System.out
.println("Time escape: " + (endTime - beginTime) / 1000 + "s");
System.out.println();
// 输出
System.out.println("Training Number: " + trainSet.size());
System.out.println("Label Number: " + labels.size()); // 标签个数
System.out.println("Feature Number: " + features.size()); // 特征个数
// 冻结特征集
features.setStopIncrement(true);
labels.setStopIncrement(true);
InstanceSet testSet = null;
// /////////////////
if (testfile != null) {
Pipe tpipe;
if (false) {// 如果test data没有标注
tpipe = new SeriesPipes(new Pipe[] { featurePipe });
} else {
tpipe = pipe;
}