-
Notifications
You must be signed in to change notification settings - Fork 34
Open
Description
cn2num()函数的compute_value()中last_power的设计有些问题,导致只能实现一次当前单位大于之前单位,比如试验 一亿零二百三十二万零五百三十五 .
应该改为:
"""
Compute the value.
When current unit is larger than previous unit, current unit * all previous units will be used as all previous units.
e.g. '两千万' = 2000 * 10000 not 2000 + 10000
"""
value = [0]
last_power = 0
for s in integer_symbols:
if isinstance(s, CND):
value[-1] = s.value
elif isinstance(s, CNU):
value[-1] *= pow(10, s.power)
print(value)
if s.power > last_power:
for i in range(len(value)-2,-1,-1):
if value[i]<pow(10, s.power):
value[i]*=pow(10, s.power)
else:
break
last_power = s.power
value.append(0)
return sum(value)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels