private void initializeChart(CfgParseChart chart, List<?> terminals) {
    Variable terminalListValue = terminalVar.getOnlyVariable();

    // Calcuate the probability of skipping each individual word,
    // if that operation is permitted.
    double[] skipProbs = null;
    if (canSkipTerminals) {
      skipProbs = calculateSkipProbabilities(terminals);
    }

    for (int i = 0; i < terminals.size(); i++) {
      for (int j = i; j < terminals.size(); j++) {
        if (terminalListValue.canTakeValue(terminals.subList(i, j + 1))) {
          Assignment assignment = terminalVar.outcomeArrayToAssignment(terminals.subList(i, j + 1));

          DiscreteFactor terminalRules = terminalDistribution.conditional(assignment);
          chart.updateInsideEntryTerminal(i, j, i, j, terminalRules);
          
          if (canSkipTerminals) {
            if (i != 0) {
              DiscreteFactor skipTerminals = getWordSkipTerminalDistribution(terminalRules, 0, j,
                  i, j, skipProbs);
              chart.updateInsideEntryTerminal(0, j, i, j, skipTerminals);
            }

            for (int k = j + 1; k < terminals.size(); k++) {
              DiscreteFactor skipTerminals = getWordSkipTerminalDistribution(terminalRules, i, k,
                  i, j, skipProbs);
              chart.updateInsideEntryTerminal(i, k, i, j, skipTerminals);
              if (i != 0) {
                skipTerminals = getWordSkipTerminalDistribution(terminalRules, 0, k,
                  i, j, skipProbs);
                chart.updateInsideEntryTerminal(0, k, i, j, skipTerminals);
              }
            }
          }
        }
      }
    }
  }
private void initializeChart ( CfgParseChart chart , List < ? > terminals ) { Variable terminalListValue = terminalVar . getOnlyVariable ( ) ; double [ ] skipProbs = null ; if ( canSkipTerminals ) { skipProbs = calculateSkipProbabilities ( terminals ) ; } for ( int i = 0 ; i < terminals . size ( ) ; i ++ ) { for ( int j = i ; j < terminals . size ( ) ; j ++ ) { if ( terminalListValue . canTakeValue ( terminals . subList ( i , j + 1 ) ) ) { Assignment assignment = terminalVar . outcomeArrayToAssignment ( terminals . subList ( i , j + 1 ) ) ; DiscreteFactor terminalRules = terminalDistribution . conditional ( assignment ) ; chart . updateInsideEntryTerminal ( i , j , i , j , terminalRules ) ; if ( canSkipTerminals ) { if ( i != 0 ) { DiscreteFactor skipTerminals = getWordSkipTerminalDistribution ( terminalRules , 0 , j , i , j , skipProbs ) ; chart . updateInsideEntryTerminal ( 0 , j , i , j , skipTerminals ) ; } for ( int k = j + 1 ; k < terminals . size ( ) ; k ++ ) { DiscreteFactor skipTerminals = getWordSkipTerminalDistribution ( terminalRules , i , k , i , j , skipProbs ) ; chart . updateInsideEntryTerminal ( i , k , i , j , skipTerminals ) ; if ( i != 0 ) { skipTerminals = getWordSkipTerminalDistribution ( terminalRules , 0 , k , i , j , skipProbs ) ; chart . updateInsideEntryTerminal ( 0 , k , i , j , skipTerminals ) ; } } } } } } }
/*
Fill in the initial chart entries implied by the given set of terminals.