Code Duplication    Length = 44-44 lines in 2 locations

abydos/phonetic.py 2 locations

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