private void loadFeatureWeight(BufferedReader br, int[] statusCoven, List<Pair<String, String>> featureNames)
                    throws Exception {

        int key = 0;

        int offe = 0;

        int tag = 0; // 赏析按标签为用来转换

        int len = 0; // 权重数组的大小

        int min, max = 0; // 设置边界

        String name = null; // 特征名称

        float[] tempW = null; // 每一个特征的权重

        String temp = br.readLine();

        for (Pair<String, String> pair : featureNames) {

            if (temp == null) {
                logger.warn(pair.getValue0() + "\t" + pair.getValue1() + " not have any weight ,so skip it !");
                continue;
            }

            char fc = Character.toUpperCase(pair.getValue0().charAt(0));

            len = fc == 'B' ? Config.TAG_NUM * Config.TAG_NUM
                            : fc == 'U' ? Config.TAG_NUM
                                            : fc == '*' ? (Config.TAG_NUM + Config.TAG_NUM * Config.TAG_NUM) : 0;

            if (len == 0) {
                throw new Exception("unknow feature type " + pair.getValue0());
            }

            min = max;
            max += len;
            if (fc == 'B') { // 特殊处理转换特征数组
                for (int i = 0; i < len; i++) {
                    String[] split = temp.split("=");
                    int from = statusCoven[i / Config.TAG_NUM];
                    int to = statusCoven[i % Config.TAG_NUM];
                    status[from][to] = ObjConver.getFloatValue(split[1]);
                    temp = br.readLine();
                }
            } else {

                name = pair.getValue1();

                tempW = new float[len];

                do {
                    String[] split = temp.split("=");

                    key = ObjConver.getIntValue(split[0]);

                    if (key >= max) { // 如果超过边界那么跳出
                        break;
                    }

                    offe = key - min;

                    tag = statusCoven[offe];

                    tempW[tag] = ObjConver.getFloatValue(split[1]);

                } while ((temp = br.readLine()) != null);

                this.featureTree.add(name, tempW); // 将特征增加到特征🌲中

                // printFeatureTree(name, tempW);
            }

        }

    }
private void loadFeatureWeight ( BufferedReader br , int [ ] statusCoven , List < Pair < String , String > > featureNames ) throws Exception { int key = 0 ; int offe = 0 ; int tag = 0 ; int len = 0 ; int min , max = 0 ; String name = null ; float [ ] tempW = null ; String temp = br . readLine ( ) ; for ( Pair < String , String > pair : featureNames ) { if ( temp == null ) { logger . warn ( pair . getValue0 ( ) + "\t" + pair . getValue1 ( ) + " not have any weight ,so skip it !" ) ; continue ; } char fc = Character . toUpperCase ( pair . getValue0 ( ) . charAt ( 0 ) ) ; len = fc == 'B' ? Config . TAG_NUM * Config . TAG_NUM : fc == 'U' ? Config . TAG_NUM : fc == '*' ? ( Config . TAG_NUM + Config . TAG_NUM * Config . TAG_NUM ) : 0 ; if ( len == 0 ) { throw new Exception ( "unknow feature type " + pair . getValue0 ( ) ) ; } min = max ; max += len ; if ( fc == 'B' ) { for ( int i = 0 ; i < len ; i ++ ) { String [ ] split = temp . split ( "=" ) ; int from = statusCoven [ i / Config . TAG_NUM ] ; int to = statusCoven [ i % Config . TAG_NUM ] ; status [ from ] [ to ] = ObjConver . getFloatValue ( split [ 1 ] ) ; temp = br . readLine ( ) ; } } else { name = pair . getValue1 ( ) ; tempW = new float [ len ] ; do { String [ ] split = temp . split ( "=" ) ; key = ObjConver . getIntValue ( split [ 0 ] ) ; if ( key >= max ) { break ; } offe = key - min ; tag = statusCoven [ offe ] ; tempW [ tag ] = ObjConver . getFloatValue ( split [ 1 ] ) ; } while ( ( temp = br . readLine ( ) ) != null ) ; this . featureTree . add ( name , tempW ) ; } } }
加载特征权重

@param br
@param featureNames
@param statusCoven
@throws Exception