private static ChartCell [ ] [ ] getNewChart ( Sentence sentence , CnfGrammar grammar , ChartCellType cellType , ParseType parseType , ChartCellConstraint constraint ) { ChartCell [ ] [ ] chart = new ChartCell [ sentence . size ( ) ] [ sentence . size ( ) + 1 ] ; for ( int i = 0 ; i < chart . length ; i ++ ) { for ( int j = i + 1 ; j < chart [ i ] . length ; j ++ ) { if ( parseType == ParseType . INSIDE && cellType != ChartCellType . FULL ) { throw new RuntimeException ( "Inside algorithm not implemented for cell type: " + cellType ) ; } ChartCell cell ; switch ( cellType ) { case SINGLE_HASH : chart [ i ] [ j ] = new SingleHashChartCell ( grammar , false ) ; break ; case SINGLE_HASH_BREAK_TIES : chart [ i ] [ j ] = new SingleHashChartCell ( grammar , true ) ; break ; case CONSTRAINED_SINGLE : cell = new SingleHashChartCell ( grammar , true ) ; chart [ i ] [ j ] = new ConstrainedChartCell ( i , j , cell , constraint , sentence ) ; break ; case DOUBLE_HASH : chart [ i ] [ j ] = new DoubleHashChartCell ( grammar ) ; break ; case FULL : chart [ i ] [ j ] = new FullChartCell ( i , j , grammar , parseType ) ; break ; case FULL_BREAK_TIES : chart [ i ] [ j ] = new FullTieBreakerChartCell ( grammar , true ) ; break ; case CONSTRAINED_FULL : cell = new FullTieBreakerChartCell ( grammar , true ) ; chart [ i ] [ j ] = new ConstrainedChartCell ( i , j , cell , constraint , sentence ) ; break ; default : throw new RuntimeException ( "not implemented for " + cellType ) ; } } } return chart ; }
Gets a new chart of the appropriate size for the sentence specific to this grammar and with cells of the specified type .