zcold / pycnnum

MIT License
19 stars 7 forks source link

alt_two = True setting results in wrong result from num2cn #5

Closed azhu26 closed 4 months ago

azhu26 commented 4 years ago

for example, if input number is 2401, the result, with alt_two=True, will also change 4 into 两。the correction should have the following line of another condition before assignment of liang in the if alt_two section of num2cn: if isinstance(v, CND) and v.value==2:

so the entire code snippet for alt_two should look like this; if alt_two: liang = CND(2, system.digits[2].alt_s, system.digits[2].alt_t, system.digits[2].big_s, system.digits[2].big_t) for i, v in enumerate(result_symbols): next_symbol = result_symbols[i + 1] if i < len(result_symbols) - 1 else None previous_symbol = result_symbols[i - 1] if i > 0 else None if isinstance(next_symbol, CNU) and isinstance(previous_symbol, (CNU, type(None))): if next_symbol.power != 1 and ((previous_symbol is None) or (previous_symbol.power != 1)): if isinstance(v, CND) and v.value==2: result_symbols[i] = liang

zcold commented 4 months ago

Fixed in the comming release