public static EdgeScores getEdgeMarginalsRealSemiring ( O2AllGraDpHypergraph graph , Scores sc ) { Algebra s = graph . getAlgebra ( ) ; int nplus = graph . getNumTokens ( ) + 1 ; Hypernode [ ] [ ] [ ] [ ] c = graph . getChart ( ) ; EdgeScores marg = new EdgeScores ( graph . getNumTokens ( ) , 0.0 ) ; for ( int width = 1 ; width < nplus ; width ++ ) { for ( int i = 0 ; i < nplus - width ; i ++ ) { int j = i + width ; for ( int g = 0 ; g < nplus ; g ++ ) { if ( i <= g && g <= j && ! ( i == 0 && g == O2AllGraDpHypergraph . NIL ) ) { continue ; } if ( j > 0 ) { marg . incrScore ( i - 1 , j - 1 , s . toReal ( sc . marginal [ c [ i ] [ j ] [ g ] [ O2AllGraDpHypergraph . INCOMPLETE ] . getId ( ) ] ) ) ; } if ( i > 0 ) { marg . incrScore ( j - 1 , i - 1 , s . toReal ( sc . marginal [ c [ j ] [ i ] [ g ] [ O2AllGraDpHypergraph . INCOMPLETE ] . getId ( ) ] ) ) ; } } } } return marg ; }
Gets the edge marginals in the real semiring from an all - grandparents hypergraph and its marginals in scores .