Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

@@ 4849-4892 (lines=44) @@
4846
    def _haase_code(word):
4847
        sdx = ''
4848
        for i in range(len(word)):
4849
            if word[i] in _vowels:
4850
                sdx += '9'
4851
            elif word[i] == 'B':
4852
                sdx += '1'
4853
            elif word[i] == 'P':
4854
                if _before(word, i, {'H'}):
4855
                    sdx += '3'
4856
                else:
4857
                    sdx += '1'
4858
            elif word[i] in {'D', 'T'}:
4859
                if _before(word, i, {'C', 'S', 'Z'}):
4860
                    sdx += '8'
4861
                else:
4862
                    sdx += '2'
4863
            elif word[i] in {'F', 'V', 'W'}:
4864
                sdx += '3'
4865
            elif word[i] in {'G', 'K', 'Q'}:
4866
                sdx += '4'
4867
            elif word[i] == 'C':
4868
                if _after(word, i, {'S', 'Z'}):
4869
                    sdx += '8'
4870
                elif i == 0:
4871
                    if _before(word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R',
4872
                                         'U', 'X'}):
4873
                        sdx += '4'
4874
                    else:
4875
                        sdx += '8'
4876
                elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
4877
                    sdx += '4'
4878
                else:
4879
                    sdx += '8'
4880
            elif word[i] == 'X':
4881
                if _after(word, i, {'C', 'K', 'Q'}):
4882
                    sdx += '8'
4883
                else:
4884
                    sdx += '48'
4885
            elif word[i] == 'L':
4886
                sdx += '5'
4887
            elif word[i] in {'M', 'N'}:
4888
                sdx += '6'
4889
            elif word[i] == 'R':
4890
                sdx += '7'
4891
            elif word[i] in {'S', 'Z'}:
4892
                sdx += '8'
4893
4894
        sdx = _delete_consecutive_repeats(sdx)
4895
@@ 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