#NEWLINE# def __getRuleSpans( self , i , j , span_phrase ) : #NEWLINE# #INDENT# 'Get the list of rules that match the phrase corresponding to the given span' #NEWLINE# global consObjsLst #NEWLINE# matchLst = PhraseTable . findConsistentRules ( span_phrase ) #NEWLINE# for match in matchLst : #NEWLINE# #INDENT# rule = match [ 0 ] #NEWLINE# if ( len ( match [ 1 ] ) == 0 ) : #NEWLINE# #INDENT# consObjsLst . append ( ConsequentRule ( rule ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( match [ 1 ] ) == 2 ) : #NEWLINE# #INDENT# span1 = ( ( match [ 1 ] [ 0 ] + i ) , ( match [ 1 ] [ 1 ] + i ) ) #NEWLINE# if ( not Parse . chartDict [ span1 ] . has_X_tree ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( settings . opts . shallow_hiero and ( not self . relaxed_decoding ) ) : #NEWLINE# #INDENT# x_level = ( - 1 ) #NEWLINE# for x_level_status in Parse . chartDict [ span1 ] . getXLevelStats ( self . sh_order ) : #NEWLINE# #INDENT# x_level += 1 #NEWLINE# if ( not x_level_status ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# consObjsLst . append ( ConsequentRule ( rule , x_level , span1 , ( ) , x_level ) ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not settings . opts . shallow_hiero ) or self . relaxed_decoding ) : #NEWLINE# #INDENT# consObjsLst . append ( ConsequentRule ( x_level_status , 0 , span1 ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( len ( match [ 1 ] ) == 4 ) : #NEWLINE# #INDENT# span1 = ( ( match [ 1 ] [ 0 ] + i ) , ( match [ 1 ] [ 1 ] + i ) ) #NEWLINE# span2 = ( ( match [ 1 ] [ 2 ] + i ) , ( match [ 1 ] [ 3 ] + i ) ) #NEWLINE# if ( ( not Parse . chartDict [ span1 ] . has_X_tree ) or ( not Parse . chartDict [ span2 ] . has_X_tree ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# if ( settings . opts . shallow_hiero and ( not self . relaxed_decoding ) ) : #NEWLINE# #INDENT# X1Levels = Parse . chartDict [ span1 ] . getXLevelStats ( self . sh_order ) #NEWLINE# X2Levels = Parse . chartDict [ span2 ] . getXLevelStats ( self . sh_order ) #NEWLINE# x1_level = ( - 1 ) #NEWLINE# top_x2_level = ( len ( X2Levels ) - 1 ) #NEWLINE# if X2Levels [ top_x2_level ] : #NEWLINE# #INDENT# for x1_level_status in X1Levels : #NEWLINE# #INDENT# x1_level += 1 #NEWLINE# if ( ( not x1_level_status ) or ( x1_level > top_x2_level ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# consObjsLst . append ( ConsequentRule ( rule , top_x2_level , span1 , span2 , x1_level , top_x2_level ) ) #NEWLINE# #UNINDENT# #UNINDENT# x2_level = ( - 1 ) #NEWLINE# top_x1_level = ( len ( X1Levels ) - 1 ) #NEWLINE# if X1Levels [ top_x1_level ] : #NEWLINE# #INDENT# for x2_level_status in X2Levels : #NEWLINE# #INDENT# x2_level += 1 #NEWLINE# if ( ( not x2_level_status ) or ( x2_level > top_x1_level ) ) : #NEWLINE# #INDENT# continue #NEWLINE# #UNINDENT# consObjsLst . append ( ConsequentRule ( rule , top_x1_level , span1 , span2 , top_x1_level , x2_level ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# if ( ( not settings . opts . shallow_hiero ) or self . relaxed_decoding ) : #NEWLINE# #INDENT# consObjsLst . append ( ConsequentRule ( rule , 0 , span1 , span2 ) )