Extracted shared DP core algorithm into dp_process_position() function: 1. Added dp_input_t struct - unified input interface for DP algorithm - Contains prefix arrays, glue arrays, hyphen info - Contains K-P parameters (penalties, ratios) 2. Added dp_is_hyphen() function - unified hyphen position detection - Uses O(log n) binary search - Replaces is_hyphen_pos() function 3. Added dp_process_position() function - core DP algorithm - Processes single start position i, tries all end positions k - Contains complete demerits calculation, fitness classification - Both entry functions now call this shared core 4. Refactored process_dp_range() - Builds temporary glue arrays from ekp_paragraph_t - Creates dp_input_t and calls dp_process_position() 5. Refactored ekp_break_with_prefixes() - Directly uses input arrays to create dp_input_t - Calls dp_process_position() for each position Benefits: - Single point of maintenance: DP bugs only need fixing once - Consistency guaranteed: both paths use identical algorithm - ~100 lines of duplicate code removed - Better testability: core algorithm can be tested independently Co-authored-by: Kinneyzhang <38454496+Kinneyzhang@users.noreply.github.com>
Symbolic link
1 line
7 B
Plaintext
Symbolic link
1 line
7 B
Plaintext
./ekp_c |