private Instance[] readInstance(String corpus, FeatureMap featureMap)
    {
        IOUtil.LineIterator lineIterator = new IOUtil.LineIterator(corpus);
        List<Instance> instanceList = new LinkedList<Instance>();
        for (String line : lineIterator)
        {
            String[] cells = line.split(",");
            String text = cells[0], label = cells[1];
            List<Integer> x = extractFeature(text, featureMap);
            int y = featureMap.tagSet.add(label);
            if (y == 0)
                y = -1; // 感知机标签约定为±1
            else if (y > 1)
                throw new IllegalArgumentException("类别数大于2，目前只支持二分类。");
            instanceList.add(new Instance(x, y));
        }
        return instanceList.toArray(new Instance[0]);
    }
private Instance [ ] readInstance ( String corpus , FeatureMap featureMap ) { IOUtil . LineIterator lineIterator = new IOUtil . LineIterator ( corpus ) ; List < Instance > instanceList = new LinkedList < Instance > ( ) ; for ( String line : lineIterator ) { String [ ] cells = line . split ( "," ) ; String text = cells [ 0 ] , label = cells [ 1 ] ; List < Integer > x = extractFeature ( text , featureMap ) ; int y = featureMap . tagSet . add ( label ) ; if ( y == 0 ) y = - 1 ; else if ( y > 1 ) throw new IllegalArgumentException ( "类别数大于2，目前只支持二分类。" ) ; instanceList . add ( new Instance ( x , y ) ) ; } return instanceList . toArray ( new Instance [ 0 ] ) ; }
从语料库读取实例

@param corpus     语料库
@param featureMap 特征映射
@return 数据集