Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

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