Best Python code snippet using assertpy_python
greek.py
Source:greek.py
...9 'ά':'α', 'Î':'ε', 'ή':'η', 'ί':'ι', 'Ï':'ο', 'Ï':'Ï
', 'Ï':'Ï', 'Ϊ':'Ï', 'Ϋ':'Ï'}10r = {}11for k, v in replacements.iteritems():12 r[k] = v13def ends_with(word, suffix):14 return word[len(word) - len(suffix):] == suffix15def stem(w):16 17 18 word = ""19 for i in w:20 if i in r:21 word += r[i]22 else:23 word += i24 done = len(word) <= 325 26 ##rule-set 127 ##γιαγιαδεÏ->γιαγ, ομαδεÏ->ομαδ28 if not done:29 for suffix in [i.decode("utf8") for i in ['ιαδεÏ', 'αδεÏ', 'αδÏν']]:30 if ends_with(word, suffix):31 word = word[:len(word) - len(suffix)]32 remaining_part_does_not_end_on = True33 for s in [i.decode("utf8") for i in ['οκ', 'μαμ', 'μαν', 'μÏαμÏ', 'ÏαÏεÏ', 'γιαγ', 'νÏανÏ', 'κÏ
Ï', 'θει', 'ÏεθεÏ']]:34 if ends_with(word, s):35 remaining_part_does_not_end_on = False36 break37 if remaining_part_does_not_end_on:38 word = word + 'αδ'.decode("utf8")39 done = True40 break41 ##rule-set 242 ##καÏεδεÏ->καÏ, γηÏεδÏν->γηÏεδ43 if not done:44 for suffix in [i.decode("utf8") for i in ['εδεÏ', 'εδÏν']]:45 if ends_with(word, suffix):46 word = word[:len(word) - len(suffix)]47 for s in [i.decode("utf8") for i in ['οÏ', 'ιÏ', 'εμÏ', 'Ï
Ï', 'γηÏ', 'δαÏ', 'κÏαÏÏ', 'μιλ']]:48 if ends_with(word, s):49 word = word + 'εδ'.decode("utf8")50 break51 done = True52 break53 ##rule-set 354 ##ÏαÏÏοÏ
δÏν->ÏαÏÏ, αÏκοÏ
δεÏ->αÏκοÏ
δ55 if not done:56 for suffix in [i.decode("utf8") for i in ['οÏ
δεÏ', 'οÏ
δÏν']]:57 if ends_with(word, suffix):58 word = word[:len(word) - len(suffix)]59 for s in [i.decode("utf8") for i in ['αÏκ', 'καλιακ', 'ÏεÏαλ', 'λιÏ', 'Ïλεξ', 'Ïκ', 'Ï', 'Ïλ', 'ÏÏ', 'βελ', 'λοÏ
λ', 'Ïν', 'ÏÏ', 'ÏÏαγ', 'Ïε']]:60 if ends_with(word, s):61 word = word + 'οÏ
δ'.decode("utf8")62 break63 done = True64 break65 ##rule-set 466 ##Ï
ÏοθεÏεÏÏ->Ï
ÏοθεÏ, θεÏν->θε67 if not done:68 for suffix in [i.decode("utf8") for i in ['εÏÏ', 'εÏν']]:69 if ends_with(word, suffix):70 word = word[:len(word) - len(suffix)]71 for s in [i.decode("utf8") for i in ['θ', 'δ', 'ελ', 'γαλ', 'ν', 'Ï', 'ιδ', 'ÏαÏ']]:72 if ends_with(word, s):73 word = word + 'ε'.decode("utf8")74 break75 done = True76 break77 ##rule-set 578 ##Ïαιδια->Ïαιδ, ÏελειοÏ
->Ïελει79 if not done:80 for suffix in [i.decode("utf8") for i in ['ια', 'ιοÏ
', 'ιÏν']]:81 if ends_with(word, suffix):82 word = word[:len(word) - len(suffix)]83 for s in VOWELS:84 if ends_with(word, s):85 word = word + 'ι'.decode("utf8")86 break87 done = True88 break89 ##rule-set 690 ##ζηλιαÏικο->ζηλιαÏ, αγÏοικοÏ->αγÏοικ91 if not done:92 for suffix in [i.decode("utf8") for i in ['ικα', 'ικοÏ
', 'ικÏν', 'ικοÏ', 'ικο', 'ικη']]:93 if ends_with(word, suffix):94 word = word[:len(word) - len(suffix)]95 if word in [i.decode("utf8") for i in ['αλ', 'αδ', 'ενδ', 'αμαν', 'αμμοÏαλ', 'ηθ', 'ανηθ', 'ανÏιδ', 'ÏÏ
Ï', 'βÏÏμ', 'γεÏ', 'εξÏδ', 'καλÏ',96 'καλλιν', 'καÏαδ', 'μοÏ
λ', 'μÏαν', 'μÏαγιαÏ', 'μÏολ', 'μÏοÏ', 'νιÏ', 'ξικ', 'ÏÏ
νομηλ', 'ÏεÏÏ', 'ÏιÏÏ',97 'ÏικανÏ', 'ÏλιαÏÏ', 'ÏονÏ', 'ÏοÏÏελν', 'ÏÏÏÏοδ', 'ÏεÏÏ', 'ÏÏ
ναδ', 'ÏÏαμ', 'Ï
Ïοδ', 'Ïιλον', 'ÏÏ
λοδ',98 'ÏαÏ']]:99 word = word + 'ικ'.decode("utf8")100 else:101 for s in VOWELS:102 if ends_with(word, s):103 word = word + 'ικ'.decode("utf8")104 break105 done = True106 break107 ##rule-set 7108 ##αγαÏαγαμε->αγαÏ, αναÏαμε->αναÏαμ109 if not done:110 if word == 'αγαμε'.decode("utf8"): word = 2*word111 for suffix in [i.decode("utf8") for i in ['ηθηκαμε', 'αγαμε', 'ηÏαμε', 'οÏ
Ïαμε', 'ηκαμε']]:112 if ends_with(word, suffix):113 word = word[:len(word) - len(suffix)]114 if word in ['Ï'.decode("utf8")]:115 word = word + 'αγαμ'.decode("utf8")116 done = True117 break118 if not done and ends_with(word, 'αμε'.decode("utf8")):119 word = word[:len(word) - len('αμε'.decode("utf8"))]120 if word in [i.decode("utf8") for i in ['αναÏ', 'αÏοθ', 'αÏοκ', 'αÏοÏÏ', 'βοÏ
β', 'ξεθ', 'οÏ
λ', 'Ïεθ', 'ÏικÏ', 'ÏοÏ', 'ÏιÏ', 'Ï']]:121 word = word + 'αμ'.decode("utf8")122 done = True123 ##rule-set 8124 ##αγαÏηÏαμε->αγαÏ, ÏÏαγανε->ÏÏαγαν125 if not done:126 for suffix in [i.decode("utf8") for i in ['ιοÏ
νÏανε', 'ιονÏανε', 'οÏ
νÏανε', 'ηθηκανε', 'οÏ
Ïανε', 'ιοÏανε', 'ονÏανε', 'αγανε', 'ηÏανε',127 'οÏανε', 'ηκανε']]:128 if ends_with(word, suffix):129 word = word[:len(word) - len(suffix)]130 if word in [i.decode("utf8") for i in ['ÏÏ', 'ÏÏ', 'Ï']]:131 word = word + 'αγαν'.decode("utf8")132 done = True133 break134 if not done and ends_with(word, 'ανε'.decode("utf8")):135 word = word[:len(word) - len('αμε'.decode("utf8"))]136 if word in [i.decode("utf8") for i in ['βεÏεÏ', 'βοÏ
λκ', 'βÏαÏμ', 'γ', 'δÏαδοÏ
μ', 'θ', 'καλÏοÏ
ζ', 'καÏÏελ', 'κοÏμοÏ', 'λαοÏλ', 'μÏαμεθ', 'μ',137 'μοÏ
ÏοÏ
λμ', 'ν', 'οÏ
λ', 'Ï', 'Ïελεκ', 'Ïλ', 'ÏολιÏ', 'ÏοÏÏολ', 'ÏαÏακαÏÏ', 'ÏοÏ
λÏ', 'ÏÏαÏλαÏ', 'οÏÏ',138 'ÏÏιγγ', 'ÏÏοÏ', 'ÏÏÏοÏÏεÏ', 'Ï', 'ÏÏ
ÏοÏλ', 'αγ', 'οÏÏ', 'γαλ', 'γεÏ', 'δεκ', 'διÏλ', 'αμεÏικαν', 'οÏ
Ï',139 'Ïιθ', 'ÏοÏ
ÏιÏ', 'Ï', 'ζÏνÏ', 'ικ', 'καÏÏ', 'κοÏ', 'λιÏ', 'λοÏ
θηÏ', 'μαινÏ', 'μελ', 'Ïιγ', 'ÏÏ', 'ÏÏεγ',140 'ÏÏαγ', 'ÏÏαγ', 'Ï', 'εÏ', 'αδαÏ', 'αθιγγ', 'αμηÏ', 'ανικ', 'ανοÏγ', 'αÏηγ', 'αÏιθ', 'αÏÏιγγ', 'βαÏ',141 'βαÏκ', 'βαθÏ
γαλ', 'βιομηÏ', 'βÏαÏÏ
κ', 'διαÏ', 'διαÏ', 'ενοÏγ', 'θÏ
Ï', 'καÏνοβιομηÏ', 'καÏαγαλ', 'κλιβ',142 'κοιλαÏÏ', 'λιβ', 'μεγλοβιομηÏ', 'μικÏοβιομηÏ', 'νÏαβ', 'ξηÏοκλιβ', 'ολιγοδαμ', 'ολογαλ', 'ÏενÏαÏÏ',143 'ÏεÏηÏ', 'ÏεÏιÏÏ', 'ÏλαÏ', 'ÏολÏ
δαÏ', 'ÏολÏ
μηÏ', 'ÏÏεÏ', 'Ïαβ', 'ÏεÏ', 'Ï
ÏεÏηÏ', 'Ï
ÏοκοÏ', 'ÏαμηλοδαÏ',144 'ÏηλοÏαβ']]:145 word = word + 'αν'.decode("utf8")146 else:147 for s in VOWELS:148 if ends_with(word, s):149 word = word + 'αν'.decode("utf8")150 break151 done = True152 ##rule-set 9153 ##αγαÏηÏεÏε->αγαÏ, βενεÏε->βενεÏ154 if not done:155 if ends_with(word, 'ηÏεÏε'.decode("utf8")):156 word = word[:len(word) - len('ηÏεÏε'.decode("utf8"))]157 done = True158 elif ends_with(word, 'εÏε'.decode("utf8")):159 word = word[:len(word) - len('εÏε'.decode("utf8"))]160 if word in [i.decode("utf8") for i in ['αβαÏ', 'βεν', 'εναÏ', 'αβÏ', 'αδ', 'αθ', 'αν', 'αÏλ', 'βαÏον', 'νÏÏ', 'Ïκ', 'κοÏ', 'μÏοÏ', 'νιÏ', 'Ïαγ',161 'ÏαÏακαλ', 'ÏεÏÏ', 'Ïκελ', 'ÏÏ
ÏÏ', 'Ïοκ', 'Ï
', 'δ', 'εμ', 'θαÏÏ', 'θ']]:162 word = word + 'εÏ'.decode("utf8")163 else:164 for s in [i.decode("utf8") for i in ['οδ', 'αιÏ', 'ÏοÏ', 'Ïαθ', 'διαθ', 'ÏÏ', 'ενδ', 'εÏ
Ï', 'Ïιθ', 'Ï
ÏεÏθ', 'Ïαθ', 'ενθ', 'Ïοθ', 'Ïθ', 'ÏÏ
Ï',165 'αιν', 'ÏÏ
νδ', 'ÏÏ
ν', 'ÏÏ
νθ', 'ÏÏÏ', 'Ïον', 'βÏ', 'καθ', 'εÏ
θ', 'εκθ', 'νεÏ', 'Ïον', 'αÏκ', 'βαÏ', 'βολ',166 'ÏÏελ']] + VOWELS:167 if ends_with(word, s):168 word = word + 'εÏ'.decode("utf8")169 break170 done = True171 ##rule-set 10172 ##αγαÏÏνÏαÏ->αγαÏ, ξενοÏÏνÏαÏ->ξενοÏÏν173 if not done:174 for suffix in [i.decode("utf8") for i in ['ονÏαÏ', 'ÏνÏαÏ']]:175 if ends_with(word, suffix):176 word = word[:len(word) - len(suffix)]177 if word in ['αÏÏ'.decode("utf8")]:178 word = word + 'ονÏ'.decode("utf8")179 elif word in [i.decode("utf8") for i in ['ξενοÏ', 'κÏε']]:180 word = word + 'ÏνÏ'.decode("utf8")181 done = True182 break183 ##rule-set 11184 ##αγαÏιομαÏÏε->αγαÏ, ονομαÏÏε->ονομαÏÏ185 if not done:186 for suffix in [i.decode("utf8") for i in ['ιομαÏÏε', 'ομαÏÏε']]:187 if ends_with(word, suffix):188 word = word[:len(word) - len(suffix)]189 if word in ['ον'.decode("utf8")]:190 word = word + 'ομαÏÏ'.decode("utf8")191 done = True192 break193 ##rule-set 12194 ##αγαÏιεÏÏε->αγαÏ, ÏιεÏÏε->ÏιεÏÏ195 if not done:196 for suffix in ['ιεÏÏε'.decode("utf8")]:197 if ends_with(word, suffix):198 word = word[:len(word) - len(suffix)]199 if word in [i.decode("utf8") for i in ['Ï', 'αÏ', 'ÏÏ
μÏ', 'αÏÏ
μÏ', 'καÏαÏ', 'μεÏαμÏ']]:200 word = word + 'ιεÏÏ'.decode("utf8")201 done = True202 break203 if not done:204 for suffix in ['εÏÏε'.decode("utf8")]:205 if ends_with(word, suffix):206 word = word[:len(word) - len(suffix)]207 if word in [i.decode("utf8") for i in ['αλ', 'αÏ', 'εκÏελ', 'ζ', 'μ', 'ξ', 'ÏαÏακαλ', 'αÏ', 'ÏÏο', 'νιÏ']]:208 word = word + 'εÏÏ'.decode("utf8")209 done = True210 break211 ##rule-set 13212 ##ÏÏιÏÏηκε->ÏÏιÏÏ, διαθηκεÏ->διαθηκ213 if not done:214 for suffix in [i.decode("utf8") for i in ['ηθηκα', 'ηθηκεÏ', 'ηθηκε']]:215 if ends_with(word, suffix):216 word = word[:len(word) - len(suffix)]217 done = True218 break219 if not done:220 for suffix in [i.decode("utf8") for i in ['ηκα', 'ηκεÏ', 'ηκε']]:221 if ends_with(word, suffix):222 word = word[:len(word) - len(suffix)]223 if word in [i.decode("utf8") for i in ['διαθ', 'θ', 'ÏαÏακαÏαθ', 'ÏÏοÏθ', 'ÏÏ
νθ']]:224 word = word + 'ηκ'.decode("utf8")225 else:226 for suffix in [i.decode("utf8") for i in ['ÏκÏλ', 'ÏκοÏ
λ', 'ναÏθ', 'ÏÏ', 'οθ', 'Ïιθ']]:227 if ends_with(word, suffix):228 word = word + 'ηκ'.decode("utf8")229 break230 done = True231 break232 233 ##rule-set 14234 ##ÏÏÏ
ÏοÏ
ÏεÏ->ÏÏÏ
Ï, μεδοÏ
ÏεÏ->μεδοÏ
Ï235 if not done:236 for suffix in [i.decode("utf8") for i in ['οÏ
Ïα', 'οÏ
ÏεÏ', 'οÏ
Ïε']]:237 if ends_with(word, suffix):238 word = word[:len(word) - len(suffix)]239 if word in [i.decode("utf8") for i in ['ÏαÏμακ', 'Ïαδ', 'αγκ', 'αναÏÏ', 'βÏομ', 'εκλιÏ', 'λαμÏιδ', 'λεÏ', 'μ', 'ÏαÏ', 'Ï', 'λ', 'μεδ', 'μεÏαζ',240 'Ï
ÏοÏειν', 'αμ', 'αιθ', 'ανηκ', 'δεÏÏοζ', 'ενδιαÏεÏ', 'δε', 'δεÏ
ÏεÏεÏ
', 'καθαÏεÏ
', 'Ïλε', 'ÏÏα']]:241 word = word + 'οÏ
Ï'.decode("utf8")242 else:243 for s in [i.decode("utf8") for i in ['ÏοδαÏ', 'βλεÏ', 'ÏανÏαÏ', 'ÏÏÏ
δ', 'μανÏιλ', 'μαλλ', 'κÏ
μαÏ', 'λαÏ', 'ληγ', 'Ïαγ', 'ομ', 'ÏÏÏÏ']] + VOWELS:244 if ends_with(word, s):245 word = word + 'οÏ
Ï'.decode("utf8")246 break247 done = True248 break249 ##rule-set 15250 #κολλαγεÏ->κολλ, αβαÏÏαγα->αβαÏÏ251 if not done:252 for suffix in [i.decode("utf8") for i in ['αγα', 'αγεÏ', 'αγε']]:253 if ends_with(word, suffix):254 word = word[:len(word) - len(suffix)]255 if word in [i.decode("utf8") for i in ['αβαÏÏ', 'ÏολÏ
Ï', 'αδηÏ', 'ÏαμÏ', 'Ï', 'αÏÏ', 'αÏ', 'αμαλ', 'αμαλλι', 'ανÏ
ÏÏ', 'αÏεÏ', 'αÏÏαÏ', 'αÏαÏ',256 'δεÏβεν', 'δÏοÏοÏ', 'ξεÏ', 'νεοÏ', 'νομοÏ', 'ολοÏ', 'ομοÏ', 'ÏÏοÏÏ', 'ÏÏοÏÏÏοÏ', 'ÏÏ
μÏ', 'ÏÏ
νÏ', 'Ï',257 'Ï
ÏοÏ', 'ÏαÏ', 'αειÏ', 'αιμοÏÏ', 'ανÏ
Ï', 'αÏοÏ', 'αÏÏιÏ', 'διαÏ', 'εν', 'εÏιÏ', 'κÏοκαλοÏ', 'ÏιδηÏοÏ',258 'λ', 'ναÏ
', 'οÏ
λαμ', 'οÏ
Ï', 'Ï', 'ÏÏ', 'μ']]:259 word = word + 'αγ'.decode("utf8")260 else:261 for s in [i.decode("utf8") for i in ['οÏ', 'Ïελ', 'ÏοÏÏ', 'ÏÏ', 'ÏÏ', 'ÏÏ', 'ÏÏ', 'λοÏ', 'Ïμην']]:262 # αÏαιÏεθηκε: 'λλ'263 if ends_with(word, s):264 if not word in ['ÏοÏ'.decode("utf8"), 'ναÏ
λοÏ'.decode("utf8")]:265 word = word + 'αγ'.decode("utf8")266 break267 done = True268 break269 ##rule-set 16270 ##αγαÏηÏε->αγαÏ, νηÏοÏ
->νηÏ271 if not done:272 for suffix in [i.decode("utf8") for i in ['ηÏε', 'ηÏοÏ
', 'ηÏα']]:273 if ends_with(word, suffix):274 word = word[:len(word) - len(suffix)]275 if word in [i.decode("utf8") for i in ['ν', 'ÏεÏÏον', 'δÏδεκαν', 'εÏημον', 'μεγαλον', 'εÏÏαν', 'αγαθον']]:276 word = word + 'ηÏ'.decode("utf8")277 done = True278 break279 280 ##rule-set 17281 ##αγαÏηÏÏε->αγαÏ, ÏβηÏÏε->ÏβηÏÏ282 if not done:283 for suffix in ['ηÏÏε'.decode("utf8")]:284 if ends_with(word, suffix):285 word = word[:len(word) - len(suffix)]286 if word in [i.decode("utf8") for i in ['αÏβ', 'Ïβ', 'αÏÏ', 'ÏÏ', 'αÏλ', 'αειμν', 'δÏ
ÏÏÏ', 'εÏ
ÏÏ', 'κοινοÏÏ', 'ÏαλιμÏ']]:287 word = word + 'ηÏÏ'.decode("utf8")288 done = True289 break290 291 ##rule-set 18292 ##αγαÏοÏ
νε->αγαÏ, ÏÏιοÏ
νε->ÏÏιοÏ
ν293 if not done:294 for suffix in [i.decode("utf8") for i in ['οÏ
νε', 'ηÏοÏ
νε', 'ηθοÏ
νε']]:295 if ends_with(word, suffix):296 word = word[:len(word) - len(suffix)]297 if word in [i.decode("utf8") for i in ['ν', 'Ï', 'ÏÏι', 'ÏÏÏαβομοÏ
ÏÏ', 'κακομοÏ
ÏÏ', 'εξÏν']]:298 word = word + 'οÏ
ν'.decode("utf8")299 done = True300 break301 302 ##rule-set 19303 ##αγαÏοÏ
με->αγαÏ, ÏοÏ
με->ÏοÏ
μ304 if not done:305 for suffix in [i.decode("utf8") for i in ['οÏ
με', 'ηÏοÏ
με', 'ηθοÏ
με']]:306 if ends_with(word, suffix):307 word = word[:len(word) - len(suffix)]308 if word in [i.decode("utf8") for i in ['ÏαÏαÏοÏ
Ï', 'Ï', 'Ï', 'ÏÏιοÏλ', 'αζ', 'αλλοÏοÏ
Ï', 'αÏοÏ
Ï']]:309 word = word + 'οÏ
μ'.decode("utf8")310 done = True311 break312 313 ##rule-set 20314 ##κÏ
μαÏα->κÏ
μ, ÏÏÏαÏο->ÏÏÏαÏ315 if not done:316 for suffix in [i.decode("utf8") for i in ['μαÏα', 'μαÏÏν', 'μαÏοÏ']]:317 if ends_with(word, suffix):318 word = word[:len(word) - len(suffix)]319 word = word + 'μ'.decode("utf8")320 done = True321 break322 323 ##rule-set 21324 if not done:325 for suffix in [i.decode("utf8") for i in ['ιονÏοÏ
Ïαν', 'ιοÏ
μαÏÏε', 'ιομαÏÏαν', 'ιοÏαÏÏαν', 'ονÏοÏ
Ïαν', 'ιοÏαÏÏε', 'ιεμαÏÏε', 'ιεÏαÏÏε', 'ιομοÏ
να',326 'ιοÏοÏ
να', 'ιοÏ
νÏαι', 'ιοÏ
νÏαν', 'ηθηκαÏε', 'ομαÏÏαν', 'οÏαÏÏαν', 'οÏ
μαÏÏε', 'ιομοÏ
ν', 'ιονÏαν', 'ιοÏοÏ
ν',327 'ηθειÏε', 'ηθηκαν', 'ομοÏ
να', 'οÏαÏÏε', 'οÏοÏ
να', 'οÏ
νÏαι', 'οÏ
νÏαν', 'οÏ
ÏαÏε', 'αγαÏε', 'ειÏαι', 'ιεμαι',328 'ιεÏαι', 'ιεÏαι', 'ιοÏαν', 'ιοÏ
μα', 'ηθειÏ', 'ηθοÏ
ν', 'ηκαÏε', 'ηÏαÏε', 'ηÏοÏ
ν', 'ομοÏ
ν', 'ονÏαι',329 'ονÏαν', 'οÏοÏ
ν', 'οÏ
μαι', 'οÏ
Ïαν', 'αγαν', 'αμαι', 'αÏαι', 'αÏαι', 'ειÏε', 'εÏαι', 'εÏαι', 'ηδεÏ',330 'ηδÏν', 'ηθει', 'ηκαν', 'ηÏαν', 'ηÏει', 'ηÏεÏ', 'ομαι', 'οÏαν', 'αει', 'ειÏ', 'ηθÏ', 'ηÏÏ', 'οÏ
ν',331 'οÏ
Ï', 'αν', 'αÏ', 'αÏ', 'ει', 'εÏ', 'ηÏ', 'οι', 'ον', 'οÏ', 'οÏ
', 'Ï
Ï', 'Ïν', 'ÏÏ', 'α', 'ε', 'ι', 'η',332 'ο', 'Ï
', 'Ï']]:333 if ends_with(word, suffix):334 word = word[:len(word) - len(suffix)]335 break336 ##rule-set 22337 ##ÏληÏιεÏÏαÏοÏ->ÏλÏ
Ïι, μεγαλÏ
ÏεÏη->μεγαλ, κονÏοÏεÏο->κονÏ338 if not done:339 for suffix in [i.decode("utf8") for i in ['εÏÏεÏ', 'εÏÏαÏ', 'οÏεÏ', 'οÏαÏ', 'Ï
ÏεÏ', 'Ï
ÏαÏ', 'ÏÏεÏ', 'ÏÏαÏ']]:340 if ends_with(word, suffix):341 word = word[:len(word) - len(suffix)]342 break343 344 if len(word) >=3: 345 return word346 return ""...
PorterStemmer.py
Source:PorterStemmer.py
...81 ch = self.word[i]82 if ch == 'w' or ch == 'x' or ch == 'y':83 return 084 return 185 def ends_with(self, s):86 """:returns TRUE when {start...end} ends with the string s."""87 length = len(s)88 if s[length - 1] != self.word[self.end]: # tiny speed-up89 return False90 if length > (self.end - self.start + 1):91 return False92 if self.word[self.end - length + 1: self.end + 1] != s:93 return False94 self.offset = self.end - length95 return True96 def set_to(self, s):97 """sets [offset + 1, end] to the characters in the string s, readjusting end."""98 length = len(s)99 self.word = self.word[:self.offset + 1] + s + self.word[self.offset + length + 1:]100 self.end = self.offset + length101 def replace_morpheme(self, s):102 """is a mapping function to change morphemes"""103 if self.m() > 0:104 self.set_to(s)105 def remove_plurals(self):106 """This is step 1 ab and gets rid of plurals and -ed or -ing. e.g.107 caresses -> caress108 ponies -> poni109 ties -> ti110 caress -> caress111 cats -> cat112 feed -> feed113 agreed -> agree114 disabled -> disable115 matting -> mat116 mating -> mate117 meeting -> meet118 milling -> mill119 messing -> mess120 meetings -> meet121 """122 if self.word[self.end] == 's':123 if self.ends_with("sses"):124 self.end = self.end - 2125 elif self.ends_with("ies"):126 self.set_to("i")127 elif self.word[self.end - 1] != 's':128 self.end = self.end - 1129 if self.ends_with("eed"):130 if self.m() > 0:131 self.end = self.end - 1132 elif (self.ends_with("ed") or self.ends_with("ing")) and self.contains_vowel():133 self.end = self.offset134 if self.ends_with("at"):135 self.set_to("ate")136 elif self.ends_with("bl"):137 self.set_to("ble")138 elif self.ends_with("iz"):139 self.set_to("ize")140 elif self.contains_double_consonant(self.end):141 self.end = self.end - 1142 ch = self.word[self.end]143 if ch == 'l' or ch == 's' or ch == 'z':144 self.end = self.end + 1145 elif self.m() == 1 and self.is_of_form_cvc(self.end):146 self.set_to("e")147 def terminal_y_to_i(self):148 """This defines step 1 c which turns terminal y to i when there is another vowel in the stem."""149 if self.ends_with('y') and self.contains_vowel():150 self.word = self.word[:self.end] + 'i' + self.word[self.end + 1:]151 def map_double_to_single_suffix(self):152 """Defines step 2 and maps double suffices to single ones.153 so -ization ( = -ize plus -ation) maps to -ize etc. note that the154 string before the suffix must give m() > 0.155 """156 if self.word[self.end - 1] == 'a':157 if self.ends_with("ational"):158 self.replace_morpheme("ate")159 elif self.ends_with("tional"):160 self.replace_morpheme("tion")161 elif self.word[self.end - 1] == 'c':162 if self.ends_with("enci"):163 self.replace_morpheme("ence")164 elif self.ends_with("anci"):165 self.replace_morpheme("ance")166 elif self.word[self.end - 1] == 'e':167 if self.ends_with("izer"): self.replace_morpheme("ize")168 elif self.word[self.end - 1] == 'l':169 if self.ends_with("bli"):170 self.replace_morpheme("ble") # --DEPARTURE--171 # To match the published algorithm, replace this phrase with172 # if self.ends("abli"): self.r("able")173 elif self.ends_with("alli"):174 self.replace_morpheme("al")175 elif self.ends_with("entli"):176 self.replace_morpheme("ent")177 elif self.ends_with("eli"):178 self.replace_morpheme("e")179 elif self.ends_with("ousli"):180 self.replace_morpheme("ous")181 elif self.word[self.end - 1] == 'o':182 if self.ends_with("ization"):183 self.replace_morpheme("ize")184 elif self.ends_with("ation"):185 self.replace_morpheme("ate")186 elif self.ends_with("ator"):187 self.replace_morpheme("ate")188 elif self.word[self.end - 1] == 's':189 if self.ends_with("alism"):190 self.replace_morpheme("al")191 elif self.ends_with("iveness"):192 self.replace_morpheme("ive")193 elif self.ends_with("fulness"):194 self.replace_morpheme("ful")195 elif self.ends_with("ousness"):196 self.replace_morpheme("ous")197 elif self.word[self.end - 1] == 't':198 if self.ends_with("aliti"):199 self.replace_morpheme("al")200 elif self.ends_with("iviti"):201 self.replace_morpheme("ive")202 elif self.ends_with("biliti"):203 self.replace_morpheme("ble")204 elif self.word[self.end - 1] == 'g':205 if self.ends_with("logi"): self.replace_morpheme("log")206 def step3(self):207 """step3() deals with -ic-, -full, -ness etc."""208 if self.word[self.end] == 'e':209 if self.ends_with("icate"):210 self.replace_morpheme("ic")211 elif self.ends_with("ative"):212 self.replace_morpheme("")213 elif self.ends_with("alize"):214 self.replace_morpheme("al")215 elif self.word[self.end] == 'i':216 if self.ends_with("iciti"): self.replace_morpheme("ic")217 elif self.word[self.end] == 'l':218 if self.ends_with("ical"):219 self.replace_morpheme("ic")220 elif self.ends_with("ful"):221 self.replace_morpheme("")222 elif self.word[self.end] == 's':223 if self.ends_with("ness"): self.replace_morpheme("")224 def step4(self):225 """step4() takes off -ant, -ence etc., in context <c>vcvc<v>."""226 if self.word[self.end - 1] == 'a':227 if self.ends_with("al"):228 pass229 else:230 return231 elif self.word[self.end - 1] == 'c':232 if self.ends_with("ance"):233 pass234 elif self.ends_with("ence"):235 pass236 else:237 return238 elif self.word[self.end - 1] == 'e':239 if self.ends_with("er"):240 pass241 else:242 return243 elif self.word[self.end - 1] == 'i':244 if self.ends_with("ic"):245 pass246 else:247 return248 elif self.word[self.end - 1] == 'l':249 if self.ends_with("able"):250 pass251 elif self.ends_with("ible"):252 pass253 else:254 return255 elif self.word[self.end - 1] == 'n':256 if self.ends_with("ant"):257 pass258 elif self.ends_with("ement"):259 pass260 elif self.ends_with("ment"):261 pass262 elif self.ends_with("ent"):263 pass264 else:265 return266 elif self.word[self.end - 1] == 'o':267 if self.ends_with("ion") and (self.word[self.offset] == 's' or self.word[self.offset] == 't'):268 pass269 elif self.ends_with("ou"):270 pass271 # takes care of -ous272 else:273 return274 elif self.word[self.end - 1] == 's':275 if self.ends_with("ism"):276 pass277 else:278 return279 elif self.word[self.end - 1] == 't':280 if self.ends_with("ate"):281 pass282 elif self.ends_with("iti"):283 pass284 else:285 return286 elif self.word[self.end - 1] == 'u':287 if self.ends_with("ous"):288 pass289 else:290 return291 elif self.word[self.end - 1] == 'v':292 if self.ends_with("ive"):293 pass294 else:295 return296 elif self.word[self.end - 1] == 'z':297 if self.ends_with("ize"):298 pass299 else:300 return301 else:302 return303 if self.m() > 1:304 self.end = self.offset305 def step5(self):306 """step5() removes a final -e if m() > 1, and changes -ll to -l if m > 1."""307 self.offset = self.end308 if self.word[self.end] == 'e':309 a = self.m()310 if a > 1 or (a == 1 and not self.is_of_form_cvc(self.end - 1)):311 self.end = self.end - 1...
porter_stemmer.py
Source:porter_stemmer.py
...79 ch = self.word[i]80 if ch == 'w' or ch == 'x' or ch == 'y':81 return 082 return 183 def ends_with(self, s):84 """:returns TRUE when {start...end} ends with the string s."""85 length = len(s)86 if s[length - 1] != self.word[self.end]: # tiny speed-up87 return False88 if length > (self.end - self.start + 1):89 return False90 if self.word[self.end - length + 1: self.end + 1] != s:91 return False92 self.offset = self.end - length93 return True94 def set_to(self, s):95 """sets [offset + 1, end] to the characters in the string s, readjusting end."""96 length = len(s)97 self.word = self.word[:self.offset + 1] + s + self.word[self.offset + length + 1:]98 self.end = self.offset + length99 def replace_morpheme(self, s):100 """is a mapping function to change morphemes"""101 if self.m() > 0:102 self.set_to(s)103 def remove_plurals(self):104 """This is step 1 ab and gets rid of plurals and -ed or -ing. e.g.105 caresses -> caress106 ponies -> poni107 ties -> ti108 caress -> caress109 cats -> cat110 feed -> feed111 agreed -> agree112 disabled -> disable113 matting -> mat114 mating -> mate115 meeting -> meet116 milling -> mill117 messing -> mess118 meetings -> meet119 """120 if self.word[self.end] == 's':121 if self.ends_with("sses"):122 self.end = self.end - 2123 elif self.ends_with("ies"):124 self.set_to("i")125 elif self.word[self.end - 1] != 's':126 self.end = self.end - 1127 if self.ends_with("eed"):128 if self.m() > 0:129 self.end = self.end - 1130 elif (self.ends_with("ed") or self.ends_with("ing")) and self.contains_vowel():131 self.end = self.offset132 if self.ends_with("at"):133 self.set_to("ate")134 elif self.ends_with("bl"):135 self.set_to("ble")136 elif self.ends_with("iz"):137 self.set_to("ize")138 elif self.contains_double_consonant(self.end):139 self.end = self.end - 1140 ch = self.word[self.end]141 if ch == 'l' or ch == 's' or ch == 'z':142 self.end = self.end + 1143 elif self.m() == 1 and self.is_of_form_cvc(self.end):144 self.set_to("e")145 def terminal_y_to_i(self):146 """This defines step 1 c which turns terminal y to i when there is another vowel in the stem."""147 if self.ends_with('y') and self.contains_vowel():148 self.word = self.word[:self.end] + 'i' + self.word[self.end + 1:]149 def map_double_to_single_suffix(self):150 """Defines step 2 and maps double suffices to single ones.151 so -ization ( = -ize plus -ation) maps to -ize etc. note that the152 string before the suffix must give m() > 0.153 """154 if self.word[self.end - 1] == 'a':155 if self.ends_with("ational"):156 self.replace_morpheme("ate")157 elif self.ends_with("tional"):158 self.replace_morpheme("tion")159 elif self.word[self.end - 1] == 'c':160 if self.ends_with("enci"):161 self.replace_morpheme("ence")162 elif self.ends_with("anci"):163 self.replace_morpheme("ance")164 elif self.word[self.end - 1] == 'e':165 if self.ends_with("izer"): self.replace_morpheme("ize")166 elif self.word[self.end - 1] == 'l':167 if self.ends_with("bli"):168 self.replace_morpheme("ble") # --DEPARTURE--169 # To match the published algorithm, replace this phrase with170 # if self.ends("abli"): self.r("able")171 elif self.ends_with("alli"):172 self.replace_morpheme("al")173 elif self.ends_with("entli"):174 self.replace_morpheme("ent")175 elif self.ends_with("eli"):176 self.replace_morpheme("e")177 elif self.ends_with("ousli"):178 self.replace_morpheme("ous")179 elif self.word[self.end - 1] == 'o':180 if self.ends_with("ization"):181 self.replace_morpheme("ize")182 elif self.ends_with("ation"):183 self.replace_morpheme("ate")184 elif self.ends_with("ator"):185 self.replace_morpheme("ate")186 elif self.word[self.end - 1] == 's':187 if self.ends_with("alism"):188 self.replace_morpheme("al")189 elif self.ends_with("iveness"):190 self.replace_morpheme("ive")191 elif self.ends_with("fulness"):192 self.replace_morpheme("ful")193 elif self.ends_with("ousness"):194 self.replace_morpheme("ous")195 elif self.word[self.end - 1] == 't':196 if self.ends_with("aliti"):197 self.replace_morpheme("al")198 elif self.ends_with("iviti"):199 self.replace_morpheme("ive")200 elif self.ends_with("biliti"):201 self.replace_morpheme("ble")202 elif self.word[self.end - 1] == 'g':203 if self.ends_with("logi"): self.replace_morpheme("log")204 def step3(self):205 """step3() deals with -ic-, -full, -ness etc."""206 if self.word[self.end] == 'e':207 if self.ends_with("icate"):208 self.replace_morpheme("ic")209 elif self.ends_with("ative"):210 self.replace_morpheme("")211 elif self.ends_with("alize"):212 self.replace_morpheme("al")213 elif self.word[self.end] == 'i':214 if self.ends_with("iciti"): self.replace_morpheme("ic")215 elif self.word[self.end] == 'l':216 if self.ends_with("ical"):217 self.replace_morpheme("ic")218 elif self.ends_with("ful"):219 self.replace_morpheme("")220 elif self.word[self.end] == 's':221 if self.ends_with("ness"): self.replace_morpheme("")222 def step4(self):223 """step4() takes off -ant, -ence etc., in context <c>vcvc<v>."""224 if self.word[self.end - 1] == 'a':225 if self.ends_with("al"):226 pass227 else:228 return229 elif self.word[self.end - 1] == 'c':230 if self.ends_with("ance"):231 pass232 elif self.ends_with("ence"):233 pass234 else:235 return236 elif self.word[self.end - 1] == 'e':237 if self.ends_with("er"):238 pass239 else:240 return241 elif self.word[self.end - 1] == 'i':242 if self.ends_with("ic"):243 pass244 else:245 return246 elif self.word[self.end - 1] == 'l':247 if self.ends_with("able"):248 pass249 elif self.ends_with("ible"):250 pass251 else:252 return253 elif self.word[self.end - 1] == 'n':254 if self.ends_with("ant"):255 pass256 elif self.ends_with("ement"):257 pass258 elif self.ends_with("ment"):259 pass260 elif self.ends_with("ent"):261 pass262 else:263 return264 elif self.word[self.end - 1] == 'o':265 if self.ends_with("ion") and (self.word[self.offset] == 's' or self.word[self.offset] == 't'):266 pass267 elif self.ends_with("ou"):268 pass269 # takes care of -ous270 else:271 return272 elif self.word[self.end - 1] == 's':273 if self.ends_with("ism"):274 pass275 else:276 return277 elif self.word[self.end - 1] == 't':278 if self.ends_with("ate"):279 pass280 elif self.ends_with("iti"):281 pass282 else:283 return284 elif self.word[self.end - 1] == 'u':285 if self.ends_with("ous"):286 pass287 else:288 return289 elif self.word[self.end - 1] == 'v':290 if self.ends_with("ive"):291 pass292 else:293 return294 elif self.word[self.end - 1] == 'z':295 if self.ends_with("ize"):296 pass297 else:298 return299 else:300 return301 if self.m() > 1:302 self.end = self.offset303 def step5(self):304 """step5() removes a final -e if m() > 1, and changes -ll to -l if m > 1."""305 self.offset = self.end306 if self.word[self.end] == 'e':307 a = self.m()308 if a > 1 or (a == 1 and not self.is_of_form_cvc(self.end - 1)):309 self.end = self.end - 1...
features.py
Source:features.py
...19 return helper.followed_by(['am','is','was','are','will','were','become','becomes','became','seem','seems','seemed'])(L, i)20def is_preceded_by_common_linking_verb(L, i):21 return helper.preceded_by(['am','is','was','are','will','were','become','becomes','became','seem','seems','seemed'])(L, i)22def ends_in_ly(L, i):23 return helper.ends_with("ly")(L, i)24def ends_in_able(L, i):25 return helper.ends_with("able")(L, i)26def ends_in_ible(L, i):27 return helper.ends_with("ible")(L, i)28def ends_in_al(L, i):29 return helper.ends_with("al")(L, i)30def ends_in_an(L, i):31 return helper.ends_with("an")(L, i)32def ends_in_ar(L, i):33 return helper.ends_with("ar")(L, i)34def ends_in_ent(L, i):35 return helper.ends_with("ent")(L, i)36def ends_in_ful(L, i):37 return helper.ends_with("ful")(L, i)38def ends_in_ic(L, i):39 return helper.ends_with("ic")(L, i)40def ends_in_ical(L, i):41 return helper.ends_with("ical")(L, i)42def ends_in_ine(L, i):43 return helper.ends_with("ine")(L, i)44def ends_in_ile(L, i):45 return helper.ends_with("ile")(L, i)46def ends_in_ive(L, i):47 return helper.ends_with("ive")(L, i)48def ends_in_less(L, i):49 return helper.ends_with("less")(L, i)50def ends_in_ous(L, i):51 return helper.ends_with("ous")(L, i)52def ends_in_some(L, i):53 return helper.ends_with("some")(L, i)54def ends_in_ing(L, i):55 return helper.ends_with("ing")(L, i)56def ends_in_ed(L, i):57 return helper.ends_with("ed")(L, i)58def is_adjective(L, i):59 adjectives = helper.make_set("word_lists/adjectives.txt")60 return L[i].lower() in adjectives61def is_pronouns(L, i):62 pronouns_mods = helper.make_set("word_lists/pronouns_mod.txt")63 return L[i].lower() in pronouns_mods64def is_verb(L, i):65 verbs_mod = helper.make_set("word_lists/verbs_mod.txt")66 return L[i].lower() in verbs_mod67def is_preposition(L, i):68 prepositions_mod = helper.make_set("word_lists/prepositions_mod.txt")69 return L[i].lower() in prepositions_mod70def is_noun(L, i):71 nouns_mod = helper.make_set("word_lists/nouns_mod.txt")...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!