@@ -152,7 +152,7 @@ def four_char_walk(
152152 segcand = ""
153153 segscore = 0
154154 thisbpmf = "-" .join (bpmfinput [0 :2 ])
155- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
155+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
156156 thisbpmf = "-" .join (bpmfinput [2 :4 ])
157157 (a , b ) = two_char_walk (phrases , thisbpmf )
158158 segcand += a
@@ -163,16 +163,16 @@ def four_char_walk(
163163 segcand = ""
164164 segscore = 0
165165 thisbpmf = "-" .join (bpmfinput [0 :3 ])
166- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
166+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
167167 mybpmf = bpmfinput [3 ]
168- (segcand , segscore ) = seg_pick (mybpmf , segcand , segscore )
168+ (segcand , segscore ) = seg_pick (phrases , mybpmf , segcand , segscore )
169169 candidate .append ((segcand , segscore ))
170170 # 1234
171171 thisbpmf = "-" .join (bpmfinput [0 :4 ])
172172 if thisbpmf in phrases :
173173 segcand = ""
174174 segscore = 0
175- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
175+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
176176 candidate .append ((segcand , segscore ))
177177 #
178178 candidate .sort (key = lambda x : x [1 ], reverse = True )
@@ -195,7 +195,7 @@ def five_char_walk(
195195 segcand = ""
196196 segscore = 0
197197 mybpmf = bpmfinput [0 ]
198- (segcand , segscore ) = seg_pick (mybpmf , segcand , segscore )
198+ (segcand , segscore ) = seg_pick (phrases , mybpmf , segcand , segscore )
199199 thisbpmf = "-" .join (bpmfinput [1 :5 ])
200200 (a , b ) = four_char_walk (phrases , thisbpmf )
201201 segcand += a
@@ -211,9 +211,9 @@ def five_char_walk(
211211 segcand = ""
212212 segscore = 0
213213 thisbpmf = "-" .join (bpmfinput [0 :2 ])
214- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
214+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
215215 thisbpmf = "-" .join (bpmfinput [2 :5 ])
216- (a , b ) = three_char_walk (thisbpmf )
216+ (a , b ) = three_char_walk (phrases , thisbpmf )
217217 segcand += a
218218 segscore += b
219219 candidate .append ((segcand , segscore ))
@@ -226,7 +226,7 @@ def five_char_walk(
226226 segcand = ""
227227 segscore = 0
228228 thisbpmf = "-" .join (bpmfinput [0 :3 ])
229- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
229+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
230230 thisbpmf = "-" .join (bpmfinput [3 :5 ])
231231 (a , b ) = two_char_walk (phrases , thisbpmf )
232232 segcand += a
@@ -237,16 +237,16 @@ def five_char_walk(
237237 segcand = ""
238238 segscore = 0
239239 thisbpmf = "-" .join (bpmfinput [0 :4 ])
240- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
240+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
241241 mybpmf = bpmfinput [4 ]
242- (segcand , segscore ) = seg_pick (mybpmf , segcand , segscore )
242+ (segcand , segscore ) = seg_pick (phrases , mybpmf , segcand , segscore )
243243 candidate .append ((segcand , segscore ))
244244 # 12345
245245 if "-" .join (bpmfinput [0 :5 ]) in phrases :
246246 segcand = ""
247247 segscore = 0
248248 thisbpmf = "-" .join (bpmfinput [0 :5 ])
249- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
249+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
250250 candidate .append ((segcand , segscore ))
251251 #
252252 candidate .sort (key = lambda x : x [1 ], reverse = True )
@@ -270,9 +270,9 @@ def six_char_walk(
270270 segcand = ""
271271 segscore = 0
272272 mybpmf = bpmfinput [0 ]
273- (segcand , segscore ) = seg_pick (mybpmf , segcand , segscore )
273+ (segcand , segscore ) = seg_pick (phrases , mybpmf , segcand , segscore )
274274 thisbpmf = "-" .join (bpmfinput [1 :6 ])
275- (a , b ) = four_char_walk (phrases , thisbpmf )
275+ (a , b ) = five_char_walk (phrases , thisbpmf )
276276 segcand += a
277277 segscore += b
278278 candidate .append ((segcand , segscore ))
@@ -287,9 +287,9 @@ def six_char_walk(
287287 segcand = ""
288288 segscore = 0
289289 thisbpmf = "-" .join (bpmfinput [0 :2 ])
290- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
290+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
291291 thisbpmf = "-" .join (bpmfinput [2 :6 ])
292- (a , b ) = three_char_walk ( thisbpmf )
292+ (a , b ) = four_char_walk ( phrases , thisbpmf )
293293 segcand += a
294294 segscore += b
295295 candidate .append ((segcand , segscore ))
@@ -303,9 +303,9 @@ def six_char_walk(
303303 segcand = ""
304304 segscore = 0
305305 thisbpmf = "-" .join (bpmfinput [0 :3 ])
306- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
306+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
307307 thisbpmf = "-" .join (bpmfinput [3 :6 ])
308- (a , b ) = three_char_walk (thisbpmf )
308+ (a , b ) = three_char_walk (phrases , thisbpmf )
309309 segcand += a
310310 segscore += b
311311 candidate .append ((segcand , segscore ))
@@ -318,7 +318,7 @@ def six_char_walk(
318318 segcand = ""
319319 segscore = 0
320320 thisbpmf = "-" .join (bpmfinput [0 :4 ])
321- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
321+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
322322 thisbpmf = "-" .join (bpmfinput [4 :6 ])
323323 (a , b ) = two_char_walk (phrases , thisbpmf )
324324 segcand += a
@@ -329,44 +329,45 @@ def six_char_walk(
329329 segcand = ""
330330 segscore = 0
331331 thisbpmf = "-" .join (bpmfinput [0 :5 ])
332- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
332+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
333333 mybpmf = bpmfinput [5 ]
334- (segcand , segscore ) = seg_pick (mybpmf , segcand , segscore )
334+ (segcand , segscore ) = seg_pick (phrases , mybpmf , segcand , segscore )
335335 candidate .append ((segcand , segscore ))
336336 # 123456
337337 if "-" .join (bpmfinput [0 :6 ]) in phrases :
338338 segcand = ""
339339 segscore = 0
340340 thisbpmf = "-" .join (bpmfinput [0 :6 ])
341- (segcand , segscore ) = seg_pick (thisbpmf , segcand , segscore )
341+ (segcand , segscore ) = seg_pick (phrases , thisbpmf , segcand , segscore )
342342 candidate .append ((segcand , segscore ))
343343 #
344344 candidate .sort (key = lambda x : x [1 ], reverse = True )
345345 return candidate [0 ]
346346
347347
348348def check_bpmf_output (phrases : dict [str , list [tuple [str , float ]]], bpmf2chk : str ) -> None :
349- if len (bpmf2chk .split ("-" )) == 2 :
349+ length = len (bpmf2chk .split ("-" ))
350+ if length == 2 :
350351 (a , b ) = two_char_walk (phrases , bpmf2chk )
351352 (c , d ) = phrases [bpmf2chk ][0 ]
352353 if (a , b ) != (c , d ):
353354 print (f"{ c } { d :f} { a } { b :f} " )
354- if len ( bpmf2chk . split ( "-" )) == 3 :
355+ elif length == 3 :
355356 (a , b ) = three_char_walk (phrases , bpmf2chk )
356357 (c , d ) = phrases [bpmf2chk ][0 ]
357358 if (a , b ) != (c , d ):
358359 print (f"{ c } { d :f} { a } { b :f} " )
359- if len ( bpmf2chk . split ( "-" )) == 4 :
360+ elif length == 4 :
360361 (a , b ) = four_char_walk (phrases , bpmf2chk )
361362 (c , d ) = phrases [bpmf2chk ][0 ]
362363 if (a , b ) != (c , d ):
363364 print (f"{ c } { d :f} { a } { b :f} " )
364- if len ( bpmf2chk . split ( "-" )) == 5 :
365+ elif length == 5 :
365366 (a , b ) = five_char_walk (phrases , bpmf2chk )
366367 (c , d ) = phrases [bpmf2chk ][0 ]
367368 if (a , b ) != (c , d ):
368369 print (f"{ c } { d :f} { a } { b :f} " )
369- if len ( bpmf2chk . split ( "-" )) == 6 :
370+ elif length == 6 :
370371 (a , b ) = six_char_walk (phrases , bpmf2chk )
371372 (c , d ) = phrases [bpmf2chk ][0 ]
372373 if (a , b ) != (c , d ):
0 commit comments