@@ -30,7 +30,7 @@ def segmented_values(nodes):
3030
3131def find_top_unigram_in_lm (lm , reading ):
3232 if reading not in lm :
33- return 0
33+ return None
3434
3535 unigrams = lm [reading ]
3636 v , s = unigrams [0 ]
@@ -80,7 +80,7 @@ def promote_over_single_syllables(lineno, lm, value, reading):
8080 readings = reading .split ("-" )
8181
8282 if len (value ) != len (readings ):
83- print ("line %d, number of codepoints don't match readings" )
83+ print ("line %d, number of codepoints don't match readings" % lineno )
8484 accrue_error ()
8585 return
8686
@@ -92,6 +92,11 @@ def promote_over_single_syllables(lineno, lm, value, reading):
9292
9393 # validate data
9494 unigrams = [find_top_unigram_in_lm (lm , r ) for r in readings ]
95+ if not all (unigrams ):
96+ print ("line %d, cannot find all single-syllable readings" % lineno )
97+ accrue_error ()
98+ return
99+
95100 their_scores = sum (u [1 ] for u in unigrams )
96101
97102 if their_scores <= our_score :
@@ -128,7 +133,7 @@ def promote_over_peers(lineno, lm, value, reading):
128133
129134 top_gram = find_top_unigram_in_lm (lm , reading )
130135 if not top_gram :
131- print ("line %d, no unigrams found for reading: %s" % reading )
136+ print ("line %d, no unigrams found for reading: %s" % ( lineno , reading ) )
132137 accrue_error ()
133138 return
134139
0 commit comments