Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

@@ 589-632 (lines=44) @@
586
        return sdx
587
588
    for i in range(len(word)):
589
        if word[i] in _vowels:
590
            sdx += '0'
591
        elif word[i] == 'B':
592
            sdx += '1'
593
        elif word[i] == 'P':
594
            if _before(word, i, {'H'}):
595
                sdx += '3'
596
            else:
597
                sdx += '1'
598
        elif word[i] in {'D', 'T'}:
599
            if _before(word, i, {'C', 'S', 'Z'}):
600
                sdx += '8'
601
            else:
602
                sdx += '2'
603
        elif word[i] in {'F', 'V', 'W'}:
604
            sdx += '3'
605
        elif word[i] in {'G', 'K', 'Q'}:
606
            sdx += '4'
607
        elif word[i] == 'C':
608
            if _after(word, i, {'S', 'Z'}):
609
                sdx += '8'
610
            elif i == 0:
611
                if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U',
612
                                     'X'}):
613
                    sdx += '4'
614
                else:
615
                    sdx += '8'
616
            elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
617
                sdx += '4'
618
            else:
619
                sdx += '8'
620
        elif word[i] == 'X':
621
            if _after(word, i, {'C', 'K', 'Q'}):
622
                sdx += '8'
623
            else:
624
                sdx += '48'
625
        elif word[i] == 'L':
626
            sdx += '5'
627
        elif word[i] in {'M', 'N'}:
628
            sdx += '6'
629
        elif word[i] == 'R':
630
            sdx += '7'
631
        elif word[i] in {'S', 'Z'}:
632
            sdx += '8'
633
634
    sdx = _delete_consecutive_repeats(sdx)
635
@@ 4847-4890 (lines=44) @@
4844
    def _haase_code(word):
4845
        sdx = ''
4846
        for i in range(len(word)):
4847
            if word[i] in _vowels:
4848
                sdx += '9'
4849
            elif word[i] == 'B':
4850
                sdx += '1'
4851
            elif word[i] == 'P':
4852
                if _before(word, i, {'H'}):
4853
                    sdx += '3'
4854
                else:
4855
                    sdx += '1'
4856
            elif word[i] in {'D', 'T'}:
4857
                if _before(word, i, {'C', 'S', 'Z'}):
4858
                    sdx += '8'
4859
                else:
4860
                    sdx += '2'
4861
            elif word[i] in {'F', 'V', 'W'}:
4862
                sdx += '3'
4863
            elif word[i] in {'G', 'K', 'Q'}:
4864
                sdx += '4'
4865
            elif word[i] == 'C':
4866
                if _after(word, i, {'S', 'Z'}):
4867
                    sdx += '8'
4868
                elif i == 0:
4869
                    if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R',
4870
                                         'U', 'X'}):
4871
                        sdx += '4'
4872
                    else:
4873
                        sdx += '8'
4874
                elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
4875
                    sdx += '4'
4876
                else:
4877
                    sdx += '8'
4878
            elif word[i] == 'X':
4879
                if _after(word, i, {'C', 'K', 'Q'}):
4880
                    sdx += '8'
4881
                else:
4882
                    sdx += '48'
4883
            elif word[i] == 'L':
4884
                sdx += '5'
4885
            elif word[i] in {'M', 'N'}:
4886
                sdx += '6'
4887
            elif word[i] == 'R':
4888
                sdx += '7'
4889
            elif word[i] in {'S', 'Z'}:
4890
                sdx += '8'
4891
4892
        sdx = _delete_consecutive_repeats(sdx)
4893