| @@ 4870-4913 (lines=44) @@ | ||
| 4867 | def _haase_code(word): |
|
| 4868 | sdx = '' |
|
| 4869 | for i in range(len(word)): |
|
| 4870 | if word[i] in _vowels: |
|
| 4871 | sdx += '9' |
|
| 4872 | elif word[i] == 'B': |
|
| 4873 | sdx += '1' |
|
| 4874 | elif word[i] == 'P': |
|
| 4875 | if _before(word, i, {'H'}): |
|
| 4876 | sdx += '3' |
|
| 4877 | else: |
|
| 4878 | sdx += '1' |
|
| 4879 | elif word[i] in {'D', 'T'}: |
|
| 4880 | if _before(word, i, {'C', 'S', 'Z'}): |
|
| 4881 | sdx += '8' |
|
| 4882 | else: |
|
| 4883 | sdx += '2' |
|
| 4884 | elif word[i] in {'F', 'V', 'W'}: |
|
| 4885 | sdx += '3' |
|
| 4886 | elif word[i] in {'G', 'K', 'Q'}: |
|
| 4887 | sdx += '4' |
|
| 4888 | elif word[i] == 'C': |
|
| 4889 | if _after(word, i, {'S', 'Z'}): |
|
| 4890 | sdx += '8' |
|
| 4891 | elif i == 0: |
|
| 4892 | if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', |
|
| 4893 | 'U', 'X'}): |
|
| 4894 | sdx += '4' |
|
| 4895 | else: |
|
| 4896 | sdx += '8' |
|
| 4897 | elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}): |
|
| 4898 | sdx += '4' |
|
| 4899 | else: |
|
| 4900 | sdx += '8' |
|
| 4901 | elif word[i] == 'X': |
|
| 4902 | if _after(word, i, {'C', 'K', 'Q'}): |
|
| 4903 | sdx += '8' |
|
| 4904 | else: |
|
| 4905 | sdx += '48' |
|
| 4906 | elif word[i] == 'L': |
|
| 4907 | sdx += '5' |
|
| 4908 | elif word[i] in {'M', 'N'}: |
|
| 4909 | sdx += '6' |
|
| 4910 | elif word[i] == 'R': |
|
| 4911 | sdx += '7' |
|
| 4912 | elif word[i] in {'S', 'Z'}: |
|
| 4913 | sdx += '8' |
|
| 4914 | ||
| 4915 | sdx = _delete_consecutive_repeats(sdx) |
|
| 4916 | ||
| @@ 581-624 (lines=44) @@ | ||
| 578 | return sdx |
|
| 579 | ||
| 580 | for i in range(len(word)): |
|
| 581 | if word[i] in _vowels: |
|
| 582 | sdx += '0' |
|
| 583 | elif word[i] == 'B': |
|
| 584 | sdx += '1' |
|
| 585 | elif word[i] == 'P': |
|
| 586 | if _before(word, i, {'H'}): |
|
| 587 | sdx += '3' |
|
| 588 | else: |
|
| 589 | sdx += '1' |
|
| 590 | elif word[i] in {'D', 'T'}: |
|
| 591 | if _before(word, i, {'C', 'S', 'Z'}): |
|
| 592 | sdx += '8' |
|
| 593 | else: |
|
| 594 | sdx += '2' |
|
| 595 | elif word[i] in {'F', 'V', 'W'}: |
|
| 596 | sdx += '3' |
|
| 597 | elif word[i] in {'G', 'K', 'Q'}: |
|
| 598 | sdx += '4' |
|
| 599 | elif word[i] == 'C': |
|
| 600 | if _after(word, i, {'S', 'Z'}): |
|
| 601 | sdx += '8' |
|
| 602 | elif i == 0: |
|
| 603 | if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', |
|
| 604 | 'X'}): |
|
| 605 | sdx += '4' |
|
| 606 | else: |
|
| 607 | sdx += '8' |
|
| 608 | elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}): |
|
| 609 | sdx += '4' |
|
| 610 | else: |
|
| 611 | sdx += '8' |
|
| 612 | elif word[i] == 'X': |
|
| 613 | if _after(word, i, {'C', 'K', 'Q'}): |
|
| 614 | sdx += '8' |
|
| 615 | else: |
|
| 616 | sdx += '48' |
|
| 617 | elif word[i] == 'L': |
|
| 618 | sdx += '5' |
|
| 619 | elif word[i] in {'M', 'N'}: |
|
| 620 | sdx += '6' |
|
| 621 | elif word[i] == 'R': |
|
| 622 | sdx += '7' |
|
| 623 | elif word[i] in {'S', 'Z'}: |
|
| 624 | sdx += '8' |
|
| 625 | ||
| 626 | sdx = _delete_consecutive_repeats(sdx) |
|
| 627 | ||