Code Duplication    Length = 45-47 lines in 2 locations

abydos/phonetic/_de.py 2 locations

@@ 536-582 (lines=47) @@
533
        def _haase_code(word):
534
            sdx = ''
535
            for i in range(len(word)):
536
                if word[i] in self._uc_v_set:
537
                    sdx += '9'
538
                elif word[i] == 'B':
539
                    sdx += '1'
540
                elif word[i] == 'P':
541
                    if _before(word, i, {'H'}):
542
                        sdx += '3'
543
                    else:
544
                        sdx += '1'
545
                elif word[i] in {'D', 'T'}:
546
                    if _before(word, i, {'C', 'S', 'Z'}):
547
                        sdx += '8'
548
                    else:
549
                        sdx += '2'
550
                elif word[i] in {'F', 'V', 'W'}:
551
                    sdx += '3'
552
                elif word[i] in {'G', 'K', 'Q'}:
553
                    sdx += '4'
554
                elif word[i] == 'C':
555
                    if _after(word, i, {'S', 'Z'}):
556
                        sdx += '8'
557
                    elif i == 0:
558
                        if _before(
559
                            word,
560
                            i,
561
                            {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', 'X'},
562
                        ):
563
                            sdx += '4'
564
                        else:
565
                            sdx += '8'
566
                    elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
567
                        sdx += '4'
568
                    else:
569
                        sdx += '8'
570
                elif word[i] == 'X':
571
                    if _after(word, i, {'C', 'K', 'Q'}):
572
                        sdx += '8'
573
                    else:
574
                        sdx += '48'
575
                elif word[i] == 'L':
576
                    sdx += '5'
577
                elif word[i] in {'M', 'N'}:
578
                    sdx += '6'
579
                elif word[i] == 'R':
580
                    sdx += '7'
581
                elif word[i] in {'S', 'Z'}:
582
                    sdx += '8'
583
584
            sdx = self._delete_consecutive_repeats(sdx)
585
@@ 137-181 (lines=45) @@
134
            return sdx
135
136
        for i in range(len(word)):
137
            if word[i] in self._uc_v_set:
138
                sdx += '0'
139
            elif word[i] == 'B':
140
                sdx += '1'
141
            elif word[i] == 'P':
142
                if _before(word, i, {'H'}):
143
                    sdx += '3'
144
                else:
145
                    sdx += '1'
146
            elif word[i] in {'D', 'T'}:
147
                if _before(word, i, {'C', 'S', 'Z'}):
148
                    sdx += '8'
149
                else:
150
                    sdx += '2'
151
            elif word[i] in {'F', 'V', 'W'}:
152
                sdx += '3'
153
            elif word[i] in {'G', 'K', 'Q'}:
154
                sdx += '4'
155
            elif word[i] == 'C':
156
                if _after(word, i, {'S', 'Z'}):
157
                    sdx += '8'
158
                elif i == 0:
159
                    if _before(
160
                        word, i, {'A', 'H', 'K', 'L', 'O', 'Q', 'R', 'U', 'X'}
161
                    ):
162
                        sdx += '4'
163
                    else:
164
                        sdx += '8'
165
                elif _before(word, i, {'A', 'H', 'K', 'O', 'Q', 'U', 'X'}):
166
                    sdx += '4'
167
                else:
168
                    sdx += '8'
169
            elif word[i] == 'X':
170
                if _after(word, i, {'C', 'K', 'Q'}):
171
                    sdx += '8'
172
                else:
173
                    sdx += '48'
174
            elif word[i] == 'L':
175
                sdx += '5'
176
            elif word[i] in {'M', 'N'}:
177
                sdx += '6'
178
            elif word[i] == 'R':
179
                sdx += '7'
180
            elif word[i] in {'S', 'Z'}:
181
                sdx += '8'
182
183
        sdx = self._delete_consecutive_repeats(sdx)
184