Code Duplication    Length = 45-47 lines in 2 locations

abydos/phonetic/_de.py 2 locations

@@ 463-509 (lines=47) @@
460
        def _haase_code(word):
461
            sdx = ''
462
            for i in range(len(word)):
463
                if word[i] in self._uc_v_set:
464
                    sdx += '9'
465
                elif word[i] == 'B':
466
                    sdx += '1'
467
                elif word[i] == 'P':
468
                    if _before(word, i, {'H'}):
469
                        sdx += '3'
470
                    else:
471
                        sdx += '1'
472
                elif word[i] in {'D', 'T'}:
473
                    if _before(word, i, {'C', 'S', 'Z'}):
474
                        sdx += '8'
475
                    else:
476
                        sdx += '2'
477
                elif word[i] in {'F', 'V', 'W'}:
478
                    sdx += '3'
479
                elif word[i] in {'G', 'K', 'Q'}:
480
                    sdx += '4'
481
                elif word[i] == 'C':
482
                    if _after(word, i, {'S', 'Z'}):
483
                        sdx += '8'
484
                    elif i == 0:
485
                        if _before(
486
                            word,
487
                            i,
488
                            {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', 'X'},
489
                        ):
490
                            sdx += '4'
491
                        else:
492
                            sdx += '8'
493
                    elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
494
                        sdx += '4'
495
                    else:
496
                        sdx += '8'
497
                elif word[i] == 'X':
498
                    if _after(word, i, {'C', 'K', 'Q'}):
499
                        sdx += '8'
500
                    else:
501
                        sdx += '48'
502
                elif word[i] == 'L':
503
                    sdx += '5'
504
                elif word[i] in {'M', 'N'}:
505
                    sdx += '6'
506
                elif word[i] == 'R':
507
                    sdx += '7'
508
                elif word[i] in {'S', 'Z'}:
509
                    sdx += '8'
510
511
            sdx = self._delete_consecutive_repeats(sdx)
512
@@ 113-157 (lines=45) @@
110
            return sdx
111
112
        for i in range(len(word)):
113
            if word[i] in self._uc_v_set:
114
                sdx += '0'
115
            elif word[i] == 'B':
116
                sdx += '1'
117
            elif word[i] == 'P':
118
                if _before(word, i, {'H'}):
119
                    sdx += '3'
120
                else:
121
                    sdx += '1'
122
            elif word[i] in {'D', 'T'}:
123
                if _before(word, i, {'C', 'S', 'Z'}):
124
                    sdx += '8'
125
                else:
126
                    sdx += '2'
127
            elif word[i] in {'F', 'V', 'W'}:
128
                sdx += '3'
129
            elif word[i] in {'G', 'K', 'Q'}:
130
                sdx += '4'
131
            elif word[i] == 'C':
132
                if _after(word, i, {'S', 'Z'}):
133
                    sdx += '8'
134
                elif i == 0:
135
                    if _before(
136
                        word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', 'X'}
137
                    ):
138
                        sdx += '4'
139
                    else:
140
                        sdx += '8'
141
                elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
142
                    sdx += '4'
143
                else:
144
                    sdx += '8'
145
            elif word[i] == 'X':
146
                if _after(word, i, {'C', 'K', 'Q'}):
147
                    sdx += '8'
148
                else:
149
                    sdx += '48'
150
            elif word[i] == 'L':
151
                sdx += '5'
152
            elif word[i] in {'M', 'N'}:
153
                sdx += '6'
154
            elif word[i] == 'R':
155
                sdx += '7'
156
            elif word[i] in {'S', 'Z'}:
157
                sdx += '8'
158
159
        sdx = self._delete_consecutive_repeats(sdx)
160