ansible-later/env_27/lib/python2.7/site-packages/snowballstemmer/swedish_stemmer.py
Robert Kaussow 10aaa8e7e3 fix pytest
2019-04-11 15:56:20 +02:00

305 lines
8.5 KiB
Python

# self file was generated automatically by the Snowball to Python interpreter
from .basestemmer import BaseStemmer
from .among import Among
class SwedishStemmer(BaseStemmer):
'''
self class was automatically generated by a Snowball to Python interpreter
It implements the stemming algorithm defined by a snowball script.
'''
serialVersionUID = 1
a_0 = [
Among(u"a", -1, 1),
Among(u"arna", 0, 1),
Among(u"erna", 0, 1),
Among(u"heterna", 2, 1),
Among(u"orna", 0, 1),
Among(u"ad", -1, 1),
Among(u"e", -1, 1),
Among(u"ade", 6, 1),
Among(u"ande", 6, 1),
Among(u"arne", 6, 1),
Among(u"are", 6, 1),
Among(u"aste", 6, 1),
Among(u"en", -1, 1),
Among(u"anden", 12, 1),
Among(u"aren", 12, 1),
Among(u"heten", 12, 1),
Among(u"ern", -1, 1),
Among(u"ar", -1, 1),
Among(u"er", -1, 1),
Among(u"heter", 18, 1),
Among(u"or", -1, 1),
Among(u"s", -1, 2),
Among(u"as", 21, 1),
Among(u"arnas", 22, 1),
Among(u"ernas", 22, 1),
Among(u"ornas", 22, 1),
Among(u"es", 21, 1),
Among(u"ades", 26, 1),
Among(u"andes", 26, 1),
Among(u"ens", 21, 1),
Among(u"arens", 29, 1),
Among(u"hetens", 29, 1),
Among(u"erns", 21, 1),
Among(u"at", -1, 1),
Among(u"andet", -1, 1),
Among(u"het", -1, 1),
Among(u"ast", -1, 1)
]
a_1 = [
Among(u"dd", -1, -1),
Among(u"gd", -1, -1),
Among(u"nn", -1, -1),
Among(u"dt", -1, -1),
Among(u"gt", -1, -1),
Among(u"kt", -1, -1),
Among(u"tt", -1, -1)
]
a_2 = [
Among(u"ig", -1, 1),
Among(u"lig", 0, 1),
Among(u"els", -1, 1),
Among(u"fullt", -1, 3),
Among(u"l\u00F6st", -1, 2)
]
g_v = [17, 65, 16, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, 0, 32]
g_s_ending = [119, 127, 149]
I_x = 0
I_p1 = 0
def copy_from(self, other):
self.I_x = other.I_x
self.I_p1 = other.I_p1
super.copy_from(other)
def r_mark_regions(self):
# (, line 26
self.I_p1 = self.limit;
# test, line 29
v_1 = self.cursor
# (, line 29
# hop, line 29
c = self.cursor + 3
if 0 > c or c > self.limit:
return False
self.cursor = c
# setmark x, line 29
self.I_x = self.cursor
self.cursor = v_1
# goto, line 30
try:
while True:
v_2 = self.cursor
try:
if not self.in_grouping(SwedishStemmer.g_v, 97, 246):
raise lab1()
self.cursor = v_2
raise lab0()
except lab1: pass
self.cursor = v_2
if self.cursor >= self.limit:
return False
self.cursor += 1
except lab0: pass
# gopast, line 30
try:
while True:
try:
if not self.out_grouping(SwedishStemmer.g_v, 97, 246):
raise lab3()
raise lab2()
except lab3: pass
if self.cursor >= self.limit:
return False
self.cursor += 1
except lab2: pass
# setmark p1, line 30
self.I_p1 = self.cursor
# try, line 31
try:
# (, line 31
if not (self.I_p1 < self.I_x):
raise lab4()
self.I_p1 = self.I_x;
except lab4: pass
return True
def r_main_suffix(self):
# (, line 36
# setlimit, line 37
v_1 = self.limit - self.cursor
# tomark, line 37
if self.cursor < self.I_p1:
return False
self.cursor = self.I_p1
v_2 = self.limit_backward
self.limit_backward = self.cursor
self.cursor = self.limit - v_1
# (, line 37
# [, line 37
self.ket = self.cursor
# substring, line 37
among_var = self.find_among_b(SwedishStemmer.a_0, 37)
if among_var == 0:
self.limit_backward = v_2
return False
# ], line 37
self.bra = self.cursor
self.limit_backward = v_2
if among_var == 0:
return False
elif among_var == 1:
# (, line 44
# delete, line 44
if not self.slice_del():
return False
elif among_var == 2:
# (, line 46
if not self.in_grouping_b(SwedishStemmer.g_s_ending, 98, 121):
return False
# delete, line 46
if not self.slice_del():
return False
return True
def r_consonant_pair(self):
# setlimit, line 50
v_1 = self.limit - self.cursor
# tomark, line 50
if self.cursor < self.I_p1:
return False
self.cursor = self.I_p1
v_2 = self.limit_backward
self.limit_backward = self.cursor
self.cursor = self.limit - v_1
# (, line 50
# and, line 52
v_3 = self.limit - self.cursor
# among, line 51
if self.find_among_b(SwedishStemmer.a_1, 7) == 0:
self.limit_backward = v_2
return False
self.cursor = self.limit - v_3
# (, line 52
# [, line 52
self.ket = self.cursor
# next, line 52
if self.cursor <= self.limit_backward:
self.limit_backward = v_2
return False
self.cursor -= 1
# ], line 52
self.bra = self.cursor
# delete, line 52
if not self.slice_del():
return False
self.limit_backward = v_2
return True
def r_other_suffix(self):
# setlimit, line 55
v_1 = self.limit - self.cursor
# tomark, line 55
if self.cursor < self.I_p1:
return False
self.cursor = self.I_p1
v_2 = self.limit_backward
self.limit_backward = self.cursor
self.cursor = self.limit - v_1
# (, line 55
# [, line 56
self.ket = self.cursor
# substring, line 56
among_var = self.find_among_b(SwedishStemmer.a_2, 5)
if among_var == 0:
self.limit_backward = v_2
return False
# ], line 56
self.bra = self.cursor
if among_var == 0:
self.limit_backward = v_2
return False
elif among_var == 1:
# (, line 57
# delete, line 57
if not self.slice_del():
return False
elif among_var == 2:
# (, line 58
# <-, line 58
if not self.slice_from(u"l\u00F6s"):
return False
elif among_var == 3:
# (, line 59
# <-, line 59
if not self.slice_from(u"full"):
return False
self.limit_backward = v_2
return True
def _stem(self):
# (, line 64
# do, line 66
v_1 = self.cursor
try:
# call mark_regions, line 66
if not self.r_mark_regions():
raise lab0()
except lab0: pass
self.cursor = v_1
# backwards, line 67
self.limit_backward = self.cursor
self.cursor = self.limit
# (, line 67
# do, line 68
v_2 = self.limit - self.cursor
try:
# call main_suffix, line 68
if not self.r_main_suffix():
raise lab1()
except lab1: pass
self.cursor = self.limit - v_2
# do, line 69
v_3 = self.limit - self.cursor
try:
# call consonant_pair, line 69
if not self.r_consonant_pair():
raise lab2()
except lab2: pass
self.cursor = self.limit - v_3
# do, line 70
v_4 = self.limit - self.cursor
try:
# call other_suffix, line 70
if not self.r_other_suffix():
raise lab3()
except lab3: pass
self.cursor = self.limit - v_4
self.cursor = self.limit_backward
return True
def equals(self, o):
return isinstance(o, SwedishStemmer)
def hashCode(self):
return hash("SwedishStemmer")
class lab0(BaseException): pass
class lab1(BaseException): pass
class lab2(BaseException): pass
class lab3(BaseException): pass
class lab4(BaseException): pass