Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

@@ 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
@@ 4778-4821 (lines=44) @@
4775
    def _haase_code(word):
4776
        sdx = ''
4777
        for i in range(len(word)):
4778
            if word[i] in _vowels:
4779
                sdx += '9'
4780
            elif word[i] == 'B':
4781
                sdx += '1'
4782
            elif word[i] == 'P':
4783
                if _before(word, i, {'H'}):
4784
                    sdx += '3'
4785
                else:
4786
                    sdx += '1'
4787
            elif word[i] in {'D', 'T'}:
4788
                if _before(word, i, {'C', 'S', 'Z'}):
4789
                    sdx += '8'
4790
                else:
4791
                    sdx += '2'
4792
            elif word[i] in {'F', 'V', 'W'}:
4793
                sdx += '3'
4794
            elif word[i] in {'G', 'K', 'Q'}:
4795
                sdx += '4'
4796
            elif word[i] == 'C':
4797
                if _after(word, i, {'S', 'Z'}):
4798
                    sdx += '8'
4799
                elif i == 0:
4800
                    if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R',
4801
                                         'U', 'X'}):
4802
                        sdx += '4'
4803
                    else:
4804
                        sdx += '8'
4805
                elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
4806
                    sdx += '4'
4807
                else:
4808
                    sdx += '8'
4809
            elif word[i] == 'X':
4810
                if _after(word, i, {'C', 'K', 'Q'}):
4811
                    sdx += '8'
4812
                else:
4813
                    sdx += '48'
4814
            elif word[i] == 'L':
4815
                sdx += '5'
4816
            elif word[i] in {'M', 'N'}:
4817
                sdx += '6'
4818
            elif word[i] == 'R':
4819
                sdx += '7'
4820
            elif word[i] in {'S', 'Z'}:
4821
                sdx += '8'
4822
4823
        sdx = _delete_consecutive_repeats(sdx)
4824