Code Duplication    Length = 36-37 lines in 2 locations

abydos/stemmer/_snowball_swedish.py 1 location

@@ 99-135 (lines=37) @@
96
97
        # Step 1
98
        _r1 = word[r1_start:]
99
        if _r1[-7:] == 'heterna':
100
            word = word[:-7]
101
        elif _r1[-6:] == 'hetens':
102
            word = word[:-6]
103
        elif _r1[-5:] in {
104
            'anden',
105
            'heten',
106
            'heter',
107
            'arnas',
108
            'ernas',
109
            'ornas',
110
            'andes',
111
            'arens',
112
            'andet',
113
        }:
114
            word = word[:-5]
115
        elif _r1[-4:] in {
116
            'arna',
117
            'erna',
118
            'orna',
119
            'ande',
120
            'arne',
121
            'aste',
122
            'aren',
123
            'ades',
124
            'erns',
125
        }:
126
            word = word[:-4]
127
        elif _r1[-3:] in {'ade', 'are', 'ern', 'ens', 'het', 'ast'}:
128
            word = word[:-3]
129
        elif _r1[-2:] in {'ad', 'en', 'ar', 'er', 'or', 'as', 'es', 'at'}:
130
            word = word[:-2]
131
        elif _r1[-1:] in {'a', 'e'}:
132
            word = word[:-1]
133
        elif _r1[-1:] == 's':
134
            if len(word) > 1 and word[-2] in self._s_endings:
135
                word = word[:-1]
136
137
        # Step 2
138
        if word[r1_start:][-2:] in {'dd', 'gd', 'nn', 'dt', 'gt', 'kt', 'tt'}:

abydos/stemmer/_snowball_danish.py 1 location

@@ 102-137 (lines=36) @@
99
100
        # Step 1
101
        _r1 = word[r1_start:]
102
        if _r1[-7:] == 'erendes':
103
            word = word[:-7]
104
        elif _r1[-6:] in {'erende', 'hedens'}:
105
            word = word[:-6]
106
        elif _r1[-5:] in {
107
            'ethed',
108
            'erede',
109
            'heden',
110
            'heder',
111
            'endes',
112
            'ernes',
113
            'erens',
114
            'erets',
115
        }:
116
            word = word[:-5]
117
        elif _r1[-4:] in {
118
            'ered',
119
            'ende',
120
            'erne',
121
            'eren',
122
            'erer',
123
            'heds',
124
            'enes',
125
            'eres',
126
            'eret',
127
        }:
128
            word = word[:-4]
129
        elif _r1[-3:] in {'hed', 'ene', 'ere', 'ens', 'ers', 'ets'}:
130
            word = word[:-3]
131
        elif _r1[-2:] in {'en', 'er', 'es', 'et'}:
132
            word = word[:-2]
133
        elif _r1[-1:] == 'e':
134
            word = word[:-1]
135
        elif _r1[-1:] == 's':
136
            if len(word) > 1 and word[-2] in self._s_endings:
137
                word = word[:-1]
138
139
        # Step 2
140
        if word[r1_start:][-2:] in {'gd', 'dt', 'gt', 'kt'}: