Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

@@ 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
@@ 4871-4914 (lines=44) @@
4868
    def _haase_code(word):
4869
        sdx = ''
4870
        for i in range(len(word)):
4871
            if word[i] in _vowels:
4872
                sdx += '9'
4873
            elif word[i] == 'B':
4874
                sdx += '1'
4875
            elif word[i] == 'P':
4876
                if _before(word, i, {'H'}):
4877
                    sdx += '3'
4878
                else:
4879
                    sdx += '1'
4880
            elif word[i] in {'D', 'T'}:
4881
                if _before(word, i, {'C', 'S', 'Z'}):
4882
                    sdx += '8'
4883
                else:
4884
                    sdx += '2'
4885
            elif word[i] in {'F', 'V', 'W'}:
4886
                sdx += '3'
4887
            elif word[i] in {'G', 'K', 'Q'}:
4888
                sdx += '4'
4889
            elif word[i] == 'C':
4890
                if _after(word, i, {'S', 'Z'}):
4891
                    sdx += '8'
4892
                elif i == 0:
4893
                    if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R',
4894
                                         'U', 'X'}):
4895
                        sdx += '4'
4896
                    else:
4897
                        sdx += '8'
4898
                elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
4899
                    sdx += '4'
4900
                else:
4901
                    sdx += '8'
4902
            elif word[i] == 'X':
4903
                if _after(word, i, {'C', 'K', 'Q'}):
4904
                    sdx += '8'
4905
                else:
4906
                    sdx += '48'
4907
            elif word[i] == 'L':
4908
                sdx += '5'
4909
            elif word[i] in {'M', 'N'}:
4910
                sdx += '6'
4911
            elif word[i] == 'R':
4912
                sdx += '7'
4913
            elif word[i] in {'S', 'Z'}:
4914
                sdx += '8'
4915
4916
        sdx = _delete_consecutive_repeats(sdx)
4917