public void reweightRootEntries ( CcgChart chart ) { int spanStart = 0 ; int spanEnd = chart . size ( ) - 1 ; int numChartEntries = chart . getNumChartEntriesForSpan ( spanStart , spanEnd ) ; // Apply unary rules. ChartEntry [ ] entries = CcgBeamSearchChart . copyChartEntryArray ( chart . getChartEntriesForSpan ( spanStart , spanEnd ) , numChartEntries ) ; double [ ] probs = ArrayUtils . copyOf ( chart . getChartEntryProbsForSpan ( spanStart , spanEnd ) , numChartEntries ) ; chart . clearChartEntriesForSpan ( spanStart , spanEnd ) ; for ( int i = 0 ; i < entries . length ; i ++ ) { chart . addChartEntryForSpan ( entries [ i ] , probs [ i ] , spanStart , spanEnd , syntaxVarType ) ; applyUnaryRules ( chart , entries [ i ] , probs [ i ] , spanStart , spanEnd ) ; } chart . doneAddingChartEntriesForSpan ( spanStart , spanEnd ) ; // Apply root factor. numChartEntries = chart . getNumChartEntriesForSpan ( spanStart , spanEnd ) ; entries = CcgBeamSearchChart . copyChartEntryArray ( chart . getChartEntriesForSpan ( spanStart , spanEnd ) , numChartEntries ) ; probs = ArrayUtils . copyOf ( chart . getChartEntryProbsForSpan ( spanStart , spanEnd ) , numChartEntries ) ; chart . clearChartEntriesForSpan ( spanStart , spanEnd ) ; for ( int i = 0 ; i < entries . length ; i ++ ) { ChartEntry entry = entries [ i ] ; double rootProb = scoreRootEntry ( entry , chart ) ; chart . addChartEntryForSpan ( entry , probs [ i ] * rootProb , spanStart , spanEnd , syntaxVarType ) ; } chart . doneAddingChartEntriesForSpan ( spanStart , spanEnd ) ; }
Updates entries in the beam for the root node with a factor for the root syntactic category and any unary rules .