Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

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