| @@ 591-634 (lines=44) @@ | ||
| 588 | return sdx |
|
| 589 | ||
| 590 | for i in range(len(word)): |
|
| 591 | if word[i] in _vowels: |
|
| 592 | sdx += '0' |
|
| 593 | elif word[i] == 'B': |
|
| 594 | sdx += '1' |
|
| 595 | elif word[i] == 'P': |
|
| 596 | if _before(word, i, {'H'}): |
|
| 597 | sdx += '3' |
|
| 598 | else: |
|
| 599 | sdx += '1' |
|
| 600 | elif word[i] in {'D', 'T'}: |
|
| 601 | if _before(word, i, {'C', 'S', 'Z'}): |
|
| 602 | sdx += '8' |
|
| 603 | else: |
|
| 604 | sdx += '2' |
|
| 605 | elif word[i] in {'F', 'V', 'W'}: |
|
| 606 | sdx += '3' |
|
| 607 | elif word[i] in {'G', 'K', 'Q'}: |
|
| 608 | sdx += '4' |
|
| 609 | elif word[i] == 'C': |
|
| 610 | if _after(word, i, {'S', 'Z'}): |
|
| 611 | sdx += '8' |
|
| 612 | elif i == 0: |
|
| 613 | if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', |
|
| 614 | 'X'}): |
|
| 615 | sdx += '4' |
|
| 616 | else: |
|
| 617 | sdx += '8' |
|
| 618 | elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}): |
|
| 619 | sdx += '4' |
|
| 620 | else: |
|
| 621 | sdx += '8' |
|
| 622 | elif word[i] == 'X': |
|
| 623 | if _after(word, i, {'C', 'K', 'Q'}): |
|
| 624 | sdx += '8' |
|
| 625 | else: |
|
| 626 | sdx += '48' |
|
| 627 | elif word[i] == 'L': |
|
| 628 | sdx += '5' |
|
| 629 | elif word[i] in {'M', 'N'}: |
|
| 630 | sdx += '6' |
|
| 631 | elif word[i] == 'R': |
|
| 632 | sdx += '7' |
|
| 633 | elif word[i] in {'S', 'Z'}: |
|
| 634 | sdx += '8' |
|
| 635 | ||
| 636 | sdx = _delete_consecutive_repeats(sdx) |
|
| 637 | ||
| @@ 4789-4832 (lines=44) @@ | ||
| 4786 | def _haase_code(word): |
|
| 4787 | sdx = '' |
|
| 4788 | for i in range(len(word)): |
|
| 4789 | if word[i] in _vowels: |
|
| 4790 | sdx += '9' |
|
| 4791 | elif word[i] == 'B': |
|
| 4792 | sdx += '1' |
|
| 4793 | elif word[i] == 'P': |
|
| 4794 | if _before(word, i, {'H'}): |
|
| 4795 | sdx += '3' |
|
| 4796 | else: |
|
| 4797 | sdx += '1' |
|
| 4798 | elif word[i] in {'D', 'T'}: |
|
| 4799 | if _before(word, i, {'C', 'S', 'Z'}): |
|
| 4800 | sdx += '8' |
|
| 4801 | else: |
|
| 4802 | sdx += '2' |
|
| 4803 | elif word[i] in {'F', 'V', 'W'}: |
|
| 4804 | sdx += '3' |
|
| 4805 | elif word[i] in {'G', 'K', 'Q'}: |
|
| 4806 | sdx += '4' |
|
| 4807 | elif word[i] == 'C': |
|
| 4808 | if _after(word, i, {'S', 'Z'}): |
|
| 4809 | sdx += '8' |
|
| 4810 | elif i == 0: |
|
| 4811 | if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', |
|
| 4812 | 'U', 'X'}): |
|
| 4813 | sdx += '4' |
|
| 4814 | else: |
|
| 4815 | sdx += '8' |
|
| 4816 | elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}): |
|
| 4817 | sdx += '4' |
|
| 4818 | else: |
|
| 4819 | sdx += '8' |
|
| 4820 | elif word[i] == 'X': |
|
| 4821 | if _after(word, i, {'C', 'K', 'Q'}): |
|
| 4822 | sdx += '8' |
|
| 4823 | else: |
|
| 4824 | sdx += '48' |
|
| 4825 | elif word[i] == 'L': |
|
| 4826 | sdx += '5' |
|
| 4827 | elif word[i] in {'M', 'N'}: |
|
| 4828 | sdx += '6' |
|
| 4829 | elif word[i] == 'R': |
|
| 4830 | sdx += '7' |
|
| 4831 | elif word[i] in {'S', 'Z'}: |
|
| 4832 | sdx += '8' |
|
| 4833 | ||
| 4834 | sdx = _delete_consecutive_repeats(sdx) |
|
| 4835 | ||