1//! This file was generated automatically by the Snowball to Go compiler
2//! http://snowballstem.org/
3
4package swedish
5
6import (
7	snowballRuntime "github.com/blevesearch/snowballstem"
8)
9
10var A_0 = []*snowballRuntime.Among{
11	{Str: "a", A: -1, B: 1, F: nil},
12	{Str: "arna", A: 0, B: 1, F: nil},
13	{Str: "erna", A: 0, B: 1, F: nil},
14	{Str: "heterna", A: 2, B: 1, F: nil},
15	{Str: "orna", A: 0, B: 1, F: nil},
16	{Str: "ad", A: -1, B: 1, F: nil},
17	{Str: "e", A: -1, B: 1, F: nil},
18	{Str: "ade", A: 6, B: 1, F: nil},
19	{Str: "ande", A: 6, B: 1, F: nil},
20	{Str: "arne", A: 6, B: 1, F: nil},
21	{Str: "are", A: 6, B: 1, F: nil},
22	{Str: "aste", A: 6, B: 1, F: nil},
23	{Str: "en", A: -1, B: 1, F: nil},
24	{Str: "anden", A: 12, B: 1, F: nil},
25	{Str: "aren", A: 12, B: 1, F: nil},
26	{Str: "heten", A: 12, B: 1, F: nil},
27	{Str: "ern", A: -1, B: 1, F: nil},
28	{Str: "ar", A: -1, B: 1, F: nil},
29	{Str: "er", A: -1, B: 1, F: nil},
30	{Str: "heter", A: 18, B: 1, F: nil},
31	{Str: "or", A: -1, B: 1, F: nil},
32	{Str: "s", A: -1, B: 2, F: nil},
33	{Str: "as", A: 21, B: 1, F: nil},
34	{Str: "arnas", A: 22, B: 1, F: nil},
35	{Str: "ernas", A: 22, B: 1, F: nil},
36	{Str: "ornas", A: 22, B: 1, F: nil},
37	{Str: "es", A: 21, B: 1, F: nil},
38	{Str: "ades", A: 26, B: 1, F: nil},
39	{Str: "andes", A: 26, B: 1, F: nil},
40	{Str: "ens", A: 21, B: 1, F: nil},
41	{Str: "arens", A: 29, B: 1, F: nil},
42	{Str: "hetens", A: 29, B: 1, F: nil},
43	{Str: "erns", A: 21, B: 1, F: nil},
44	{Str: "at", A: -1, B: 1, F: nil},
45	{Str: "andet", A: -1, B: 1, F: nil},
46	{Str: "het", A: -1, B: 1, F: nil},
47	{Str: "ast", A: -1, B: 1, F: nil},
48}
49
50var A_1 = []*snowballRuntime.Among{
51	{Str: "dd", A: -1, B: -1, F: nil},
52	{Str: "gd", A: -1, B: -1, F: nil},
53	{Str: "nn", A: -1, B: -1, F: nil},
54	{Str: "dt", A: -1, B: -1, F: nil},
55	{Str: "gt", A: -1, B: -1, F: nil},
56	{Str: "kt", A: -1, B: -1, F: nil},
57	{Str: "tt", A: -1, B: -1, F: nil},
58}
59
60var A_2 = []*snowballRuntime.Among{
61	{Str: "ig", A: -1, B: 1, F: nil},
62	{Str: "lig", A: 0, B: 1, F: nil},
63	{Str: "els", A: -1, B: 1, F: nil},
64	{Str: "fullt", A: -1, B: 3, F: nil},
65	{Str: "l\u00F6st", A: -1, B: 2, F: nil},
66}
67
68var G_v = []byte{17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 32}
69
70var G_s_ending = []byte{119, 127, 149}
71
72type Context struct {
73	i_x  int
74	i_p1 int
75}
76
77func r_mark_regions(env *snowballRuntime.Env, ctx interface{}) bool {
78	context := ctx.(*Context)
79	_ = context
80	// (, line 26
81	context.i_p1 = env.Limit
82	// test, line 29
83	var v_1 = env.Cursor
84	// (, line 29
85	{
86		// hop, line 29
87		var c = env.ByteIndexForHop((3))
88		if int32(0) > c || c > int32(env.Limit) {
89			return false
90		}
91		env.Cursor = int(c)
92	}
93	// setmark x, line 29
94	context.i_x = env.Cursor
95	env.Cursor = v_1
96	// goto, line 30
97golab0:
98	for {
99		var v_2 = env.Cursor
100	lab1:
101		for {
102			if !env.InGrouping(G_v, 97, 246) {
103				break lab1
104			}
105			env.Cursor = v_2
106			break golab0
107		}
108		env.Cursor = v_2
109		if env.Cursor >= env.Limit {
110			return false
111		}
112		env.NextChar()
113	}
114	// gopast, line 30
115golab2:
116	for {
117	lab3:
118		for {
119			if !env.OutGrouping(G_v, 97, 246) {
120				break lab3
121			}
122			break golab2
123		}
124		if env.Cursor >= env.Limit {
125			return false
126		}
127		env.NextChar()
128	}
129	// setmark p1, line 30
130	context.i_p1 = env.Cursor
131	// try, line 31
132lab4:
133	for {
134		// (, line 31
135		if !(context.i_p1 < context.i_x) {
136			break lab4
137		}
138		context.i_p1 = context.i_x
139		break lab4
140	}
141	return true
142}
143
144func r_main_suffix(env *snowballRuntime.Env, ctx interface{}) bool {
145	context := ctx.(*Context)
146	_ = context
147	var among_var int32
148	// (, line 36
149	// setlimit, line 37
150	var v_1 = env.Limit - env.Cursor
151	// tomark, line 37
152	if env.Cursor < context.i_p1 {
153		return false
154	}
155	env.Cursor = context.i_p1
156	var v_2 = env.LimitBackward
157	env.LimitBackward = env.Cursor
158	env.Cursor = env.Limit - v_1
159	// (, line 37
160	// [, line 37
161	env.Ket = env.Cursor
162	// substring, line 37
163	among_var = env.FindAmongB(A_0, context)
164	if among_var == 0 {
165		env.LimitBackward = v_2
166		return false
167	}
168	// ], line 37
169	env.Bra = env.Cursor
170	env.LimitBackward = v_2
171	if among_var == 0 {
172		return false
173	} else if among_var == 1 {
174		// (, line 44
175		// delete, line 44
176		if !env.SliceDel() {
177			return false
178		}
179	} else if among_var == 2 {
180		// (, line 46
181		if !env.InGroupingB(G_s_ending, 98, 121) {
182			return false
183		}
184		// delete, line 46
185		if !env.SliceDel() {
186			return false
187		}
188	}
189	return true
190}
191
192func r_consonant_pair(env *snowballRuntime.Env, ctx interface{}) bool {
193	context := ctx.(*Context)
194	_ = context
195	// setlimit, line 50
196	var v_1 = env.Limit - env.Cursor
197	// tomark, line 50
198	if env.Cursor < context.i_p1 {
199		return false
200	}
201	env.Cursor = context.i_p1
202	var v_2 = env.LimitBackward
203	env.LimitBackward = env.Cursor
204	env.Cursor = env.Limit - v_1
205	// (, line 50
206	// and, line 52
207	var v_3 = env.Limit - env.Cursor
208	// among, line 51
209	if env.FindAmongB(A_1, context) == 0 {
210		env.LimitBackward = v_2
211		return false
212	}
213	env.Cursor = env.Limit - v_3
214	// (, line 52
215	// [, line 52
216	env.Ket = env.Cursor
217	// next, line 52
218	if env.Cursor <= env.LimitBackward {
219		env.LimitBackward = v_2
220		return false
221	}
222	env.PrevChar()
223	// ], line 52
224	env.Bra = env.Cursor
225	// delete, line 52
226	if !env.SliceDel() {
227		return false
228	}
229	env.LimitBackward = v_2
230	return true
231}
232
233func r_other_suffix(env *snowballRuntime.Env, ctx interface{}) bool {
234	context := ctx.(*Context)
235	_ = context
236	var among_var int32
237	// setlimit, line 55
238	var v_1 = env.Limit - env.Cursor
239	// tomark, line 55
240	if env.Cursor < context.i_p1 {
241		return false
242	}
243	env.Cursor = context.i_p1
244	var v_2 = env.LimitBackward
245	env.LimitBackward = env.Cursor
246	env.Cursor = env.Limit - v_1
247	// (, line 55
248	// [, line 56
249	env.Ket = env.Cursor
250	// substring, line 56
251	among_var = env.FindAmongB(A_2, context)
252	if among_var == 0 {
253		env.LimitBackward = v_2
254		return false
255	}
256	// ], line 56
257	env.Bra = env.Cursor
258	if among_var == 0 {
259		env.LimitBackward = v_2
260		return false
261	} else if among_var == 1 {
262		// (, line 57
263		// delete, line 57
264		if !env.SliceDel() {
265			return false
266		}
267	} else if among_var == 2 {
268		// (, line 58
269		// <-, line 58
270		if !env.SliceFrom("l\u00F6s") {
271			return false
272		}
273	} else if among_var == 3 {
274		// (, line 59
275		// <-, line 59
276		if !env.SliceFrom("full") {
277			return false
278		}
279	}
280	env.LimitBackward = v_2
281	return true
282}
283
284func Stem(env *snowballRuntime.Env) bool {
285	var context = &Context{
286		i_x:  0,
287		i_p1: 0,
288	}
289	_ = context
290	// (, line 64
291	// do, line 66
292	var v_1 = env.Cursor
293lab0:
294	for {
295		// call mark_regions, line 66
296		if !r_mark_regions(env, context) {
297			break lab0
298		}
299		break lab0
300	}
301	env.Cursor = v_1
302	// backwards, line 67
303	env.LimitBackward = env.Cursor
304	env.Cursor = env.Limit
305	// (, line 67
306	// do, line 68
307	var v_2 = env.Limit - env.Cursor
308lab1:
309	for {
310		// call main_suffix, line 68
311		if !r_main_suffix(env, context) {
312			break lab1
313		}
314		break lab1
315	}
316	env.Cursor = env.Limit - v_2
317	// do, line 69
318	var v_3 = env.Limit - env.Cursor
319lab2:
320	for {
321		// call consonant_pair, line 69
322		if !r_consonant_pair(env, context) {
323			break lab2
324		}
325		break lab2
326	}
327	env.Cursor = env.Limit - v_3
328	// do, line 70
329	var v_4 = env.Limit - env.Cursor
330lab3:
331	for {
332		// call other_suffix, line 70
333		if !r_other_suffix(env, context) {
334			break lab3
335		}
336		break lab3
337	}
338	env.Cursor = env.Limit - v_4
339	env.Cursor = env.LimitBackward
340	return true
341}
342