一百八 to 一百八十 一亿一千三百万 to 一亿 一千万 三百万
(integer_symbols, system)
| 252 | [get_symbol(c, system) for c in dec_string] |
| 253 | |
| 254 | def correct_symbols(integer_symbols, system): |
| 255 | """ |
| 256 | 一百八 to 一百八十 |
| 257 | 一亿一千三百万 to 一亿 一千万 三百万 |
| 258 | """ |
| 259 | |
| 260 | if integer_symbols and isinstance(integer_symbols[0], CNU): |
| 261 | if integer_symbols[0].power == 1: |
| 262 | integer_symbols = [system.digits[1]] + integer_symbols |
| 263 | |
| 264 | if len(integer_symbols) > 1: |
| 265 | if isinstance(integer_symbols[-1], CND) and isinstance(integer_symbols[-2], CNU): |
| 266 | integer_symbols.append( |
| 267 | CNU(integer_symbols[-2].power - 1, None, None, None, None)) |
| 268 | |
| 269 | result = [] |
| 270 | unit_count = 0 |
| 271 | for s in integer_symbols: |
| 272 | if isinstance(s, CND): |
| 273 | result.append(s) |
| 274 | unit_count = 0 |
| 275 | elif isinstance(s, CNU): |
| 276 | current_unit = CNU(s.power, None, None, None, None) |
| 277 | unit_count += 1 |
| 278 | |
| 279 | if unit_count == 1: |
| 280 | result.append(current_unit) |
| 281 | elif unit_count > 1: |
| 282 | for i in range(len(result)): |
| 283 | if isinstance(result[-i - 1], CNU) and result[-i - 1].power < current_unit.power: |
| 284 | result[-i - 1] = CNU(result[-i - 1].power + |
| 285 | current_unit.power, None, None, None, None) |
| 286 | return result |
| 287 | |
| 288 | def compute_value(integer_symbols): |
| 289 | """ |