MCPcopy Create free account
hub / github.com/MoonInTheRiver/DiffSinger / correct_symbols

Function correct_symbols

utils/text_norm.py:254–286  ·  view source on GitHub ↗

一百八 to 一百八十 一亿一千三百万 to 一亿 一千万 三百万

(integer_symbols, system)

Source from the content-addressed store, hash-verified

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 """

Callers 1

chn2numFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected