public Predict<int[]> getBest(Instance instance, int nbest) {
		int[][] data;
		/**
		 * 节点矩阵
		 */
		Node[][] lattice;

		data = (int[][]) instance.getData();
		// target = (int[]) instance.getTarget();
		lattice = new Node[data.length][getTemplets().numStates];
		for (int ip = 0; ip < data.length; ip++)
			for (int s = 0; s < getTemplets().numStates; s++)
				lattice[ip][s] = new Node(nbest);

		for (int ip = 0; ip < data.length; ip++) {
			// 对于每一个n阶的可能组合
			for (int s = 0; s < numStates; s++) {
				// 计算所有特征的权重和
				for (int t = 0; t < numTemplets; t++) {
					if (data[ip][t] == -1)
						continue;
					lattice[ip][s].weight += weights[data[ip][t]
							+ getTemplets().offset[t][s]];
				}
			}
		}
		for (int s = 0; s < ysize; s++) {
			lattice[0][s].best[0] = lattice[0][s].weight;
		}
		float[] best = new float[nbest];
		Integer[] prev = new Integer[nbest];
		for (int ip = 1; ip < data.length; ip++) {
			for (int s = 0; s < numStates; s += ysize) {
				Arrays.fill(best, Float.NEGATIVE_INFINITY);
				for (int k = 0; k < ysize; k++) {
					int sp = (k * getTemplets().numStates + s) / ysize;
					for (int ibest = 0; ibest < nbest; ibest++) {
						float b = lattice[ip - 1][sp].best[ibest];
						MyArrays.addBest(best, prev, b, sp * nbest + ibest);
					}
				}
				for (int r = s; r < s + ysize; r++) {
					for (int n = 0; n < nbest; n++) {
						lattice[ip][r].best[n] = best[n]
								+ lattice[ip][r].weight;
						lattice[ip][r].prev[n] = prev[n];
					}
				}
			}
		}

		Predict<int[]> res = getPath(lattice, nbest);

		return res;
	}
public Predict < int [ ] > getBest ( Instance instance , int nbest ) { int [ ] [ ] data ; Node [ ] [ ] lattice ; data = ( int [ ] [ ] ) instance . getData ( ) ; lattice = new Node [ data . length ] [ getTemplets ( ) . numStates ] ; for ( int ip = 0 ; ip < data . length ; ip ++ ) for ( int s = 0 ; s < getTemplets ( ) . numStates ; s ++ ) lattice [ ip ] [ s ] = new Node ( nbest ) ; for ( int ip = 0 ; ip < data . length ; ip ++ ) { for ( int s = 0 ; s < numStates ; s ++ ) { for ( int t = 0 ; t < numTemplets ; t ++ ) { if ( data [ ip ] [ t ] == - 1 ) continue ; lattice [ ip ] [ s ] . weight += weights [ data [ ip ] [ t ] + getTemplets ( ) . offset [ t ] [ s ] ] ; } } } for ( int s = 0 ; s < ysize ; s ++ ) { lattice [ 0 ] [ s ] . best [ 0 ] = lattice [ 0 ] [ s ] . weight ; } float [ ] best = new float [ nbest ] ; Integer [ ] prev = new Integer [ nbest ] ; for ( int ip = 1 ; ip < data . length ; ip ++ ) { for ( int s = 0 ; s < numStates ; s += ysize ) { Arrays . fill ( best , Float . NEGATIVE_INFINITY ) ; for ( int k = 0 ; k < ysize ; k ++ ) { int sp = ( k * getTemplets ( ) . numStates + s ) / ysize ; for ( int ibest = 0 ; ibest < nbest ; ibest ++ ) { float b = lattice [ ip - 1 ] [ sp ] . best [ ibest ] ; MyArrays . addBest ( best , prev , b , sp * nbest + ibest ) ; } } for ( int r = s ; r < s + ysize ; r ++ ) { for ( int n = 0 ; n < nbest ; n ++ ) { lattice [ ip ] [ r ] . best [ n ] = best [ n ] + lattice [ ip ] [ r ] . weight ; lattice [ ip ] [ r ] . prev [ n ] = prev [ n ] ; } } } } Predict < int [ ] > res = getPath ( lattice , nbest ) ; return res ; }
标记给定实例

@param instance