TELEPHONE类
| 449 | |
| 450 | |
| 451 | class TelePhone: |
| 452 | """ |
| 453 | TELEPHONE类 |
| 454 | """ |
| 455 | |
| 456 | def __init__(self, telephone=None, raw_chntext=None, chntext=None): |
| 457 | self.telephone = telephone |
| 458 | self.raw_chntext = raw_chntext |
| 459 | self.chntext = chntext |
| 460 | |
| 461 | # def chntext2telephone(self): |
| 462 | # sil_parts = self.raw_chntext.split('<SIL>') |
| 463 | # self.telephone = '-'.join([ |
| 464 | # str(chn2num(p)) for p in sil_parts |
| 465 | # ]) |
| 466 | # return self.telephone |
| 467 | |
| 468 | def telephone2chntext(self, fixed=False): |
| 469 | |
| 470 | if fixed: |
| 471 | sil_parts = self.telephone.split('-') |
| 472 | self.raw_chntext = '<SIL>'.join([ |
| 473 | num2chn(part, alt_two=False, use_units=False) for part in sil_parts |
| 474 | ]) |
| 475 | self.chntext = self.raw_chntext.replace('<SIL>', '') |
| 476 | else: |
| 477 | sp_parts = self.telephone.strip('+').split() |
| 478 | self.raw_chntext = '<SP>'.join([ |
| 479 | num2chn(part, alt_two=False, use_units=False) for part in sp_parts |
| 480 | ]) |
| 481 | self.chntext = self.raw_chntext.replace('<SP>', '') |
| 482 | return self.chntext |
| 483 | |
| 484 | |
| 485 | class Fraction: |