public double getCoverDelta ( GrammarRuleRecord rule ) { // counts which uncovered points shall be covered int new_cover = 0 ; // counts overlaps with previously covered ranges int overlapping_cover = 0 ; // perform the sum computation for ( RuleInterval i : rule . getRuleIntervals ( ) ) { int start = i . getStart ( ) ; int end = i . getEnd ( ) ; for ( int j = start ; j < end ; j ++ ) { if ( range [ j ] ) { overlapping_cover ++ ; } else { new_cover ++ ; } } } // if covers nothing, return 0 if ( 0 == new_cover ) { return 0.0 ; } // if zero overlap, return full weighted cover if ( 0 == overlapping_cover ) { return ( double ) new_cover / ( double ) ( rule . getExpandedRuleString ( ) . length ( ) + rule . getRuleIntervals ( ) . size ( ) ) ; } // else divide newly covered points amount by the sum of the rule string length and occurrence // (i.e. encoding size) return ( ( double ) new_cover / ( double ) ( new_cover + overlapping_cover ) ) / ( double ) ( rule . getExpandedRuleString ( ) . length ( ) + rule . getRuleIntervals ( ) . size ( ) ) ; }
Computes the delta value for the suggested rule candidate .