Conjugate a Turkish verb
Javascript (ES6), 466 456 451 446 bytes
(v,p,w,t)=>(R=g=>g.exec(s),T=r=>s=s.slice(0,-1)+r,Z=s=>s.replace(/\d/g,c=>l=['ıuiü'[(n='aıoueiöü'.search(l))>>1],'ae'[n>>2]][c]),(s=v.slice(k=l=0,-3)).replace(/[aıoueiöü]/g,c=>(L=l,l=c,k++)),(R(/^(gi|ta|di|gü)t$/)||(R(/et$/)&&(k=1)))&&T`d`,((E=R(/[aıoueiöü]$/))&&t==2?(l=L,T``):s)+Z([(E?'':k<2&!R(/^((k?a|bi|bu|ge|o|ö)l)|dur|gör|san|v[aeu]r$/))+'r','0yor',(E?'y1c1':'1c1')+'ğkk'[--w]][t-1])+Z('0m|0z|s0n|s0n0z||l1r'.split`|`[w+w+p],t-2||(l='o')))
Ungofled and commented
// Parameters:
// - 'v' = verb
// - 'p' = plural flag
// - 'w' = person
// - 't' = tense
(v, p, w, t) => (
// R() - Helper function to execute a regular expression on the stem.
R = g => g.exec(s),
// T() - Helper function to replace the last character of the stem with 'r'.
T = r => s = s.slice(0, -1) + r,
// Z() - Function that applies vowel harmony to the string 's', assuming
// '0' = 'i' and '1' = 'e' and using the last encountered vowel 'l'.
Z = s => s.replace(
/\d/g,
c => l = [
'ıuiü' [(n = 'aıoueiöü'.search(l)) >> 1],
'ae' [n >> 2]
][c]
),
// Computes:
// - 's' = stem
// - 'k' = number of vowels in stem
// - 'l' = last vowel in stem
// - 'L' = penultimate vowel in stem
(s = v.slice(k = l = 0, -3)).replace(/[aıoueiöü]/g, c => (L = l, l = c, k++)),
// Applies ending 't' => 'd' for irregular verbs and those ending in -et(mek).
(R(/^(gi|ta|di|gü)t$/) || (R(/et$/) && (k = 1))) && T `d`,
// Computes 'E' = truthy value if the stem ends in a vowel.
// If 'E' is truthy and the tense is the continuing present, drops this vowel.
((E = R(/[aıoueiöü]$/)) && t == 2 ? (l = L, T ``) : s) +
// Appends sign of tense with vowel harmony.
Z([
// t = 1: simple present -> either '-er', '-ir' or '-r'
(E ? '' : k < 2 & !R(/^((k?a|bi|bu|ge|o|ö)l)|dur|gör|san|v[aeu]r$/) + 'r',
// t = 2: continuing present -> always '-iyor'
'0yor',
// t = 3: future -> either '-yecek', '-ecek', '-yeceğ' or '-eceğ'
(E ? 'y1c1' : '1c1') + 'ğkk' [--w]
][t - 1]) +
// Appends personal suffix with vowel harmony,
// forcing last vowel to 'o' for continuing present.
Z(
'0m|0z|s0n|s0n0z||l1r'.split `|` [w + w + p],
t - 2 || (l = 'o')
)
)
Test cases
let f =
(v,p,w,t)=>(R=g=>g.exec(s),T=r=>s=s.slice(0,-1)+r,Z=s=>s.replace(/\d/g,c=>l=['ıuiü'[(n='aıoueiöü'.search(l))>>1],'ae'[n>>2]][c]),(s=v.slice(k=l=0,-3)).replace(/[aıoueiöü]/g,c=>(L=l,l=c,k++)),(R(/^(gi|ta|di|gü)t$/)||(R(/et$/)&&(k=1)))&&T`d`,((E=R(/[aıoueiöü]$/))&&t==2?(l=L,T``):s)+Z([(E?'':k<2&!R(/^((k?a|bi|bu|ge|o|ö)l)|dur|gör|san|v[aeu]r$/))+'r','0yor',(E?'y1c1':'1c1')+'ğkk'[--w]][t-1])+Z('0m|0z|s0n|s0n0z||l1r'.split`|`[w+w+p],t-2||(l='o')))
console.log(f("gütmek", false, 1, 2)); // -> güdüyorum
console.log(f("almak", true, 3, 3)); // -> alacaklar
console.log(f("boğmak", true, 2, 1)); // -> boğarsınız
console.log(f("ölmek", false, 3, 1)); // -> ölür
console.log(f("boyamak", true, 1, 2)); // -> boyuyoruz
console.log(f("affetmek", false, 2, 1)); // -> affedersin
console.log(f("söylemek", true, 3, 1)); // -> söylerler
console.log(f("söylemek", false, 3, 2)); // -> söylüyor
console.log(f("söylemek", false, 1, 3)); // -> söyleyeceğim
sed, 583 bytes
sed -E 's/^((bul|dur|k?al|ol|san|v[au]r)ma|(bil|gel|gör|öl|ver)me)k( . .) 1/\2\3Ir\4/;s/etmek( . .) 1/edEr\1/;s/etmek /ed /;s/^((ta)tma|([dg]i|gü)tme)k /\2\3d /;s/m[ae]k / /;s/([aıoueiöüEI])/V\1/g;s/(V.)( . .) 1/\1r\2/;s/(V.+V.+)( . .) 1/\1VIr\2/;s/( . .) 1/VEr\1/;s/(V.)?( . .) 2/VIyVor\2/;s/(V.)( . . 3)/\1y\2/;s/( . .) 3/VEcVEk\1/;s/k( . 1)/ğ\1/;s/ 0 1/VIm/;s/ 1 1/VIz/;s/ 0 2/sVIn/;s/ 1 2/sVInVIz/;s/ 0 3//;s/ 1 3/lVEr/;:l
s/([ıa][^V]*V)I/\1ı/;s/([ie][^V]*V)I/\1i/;s/([uo][^V]*V)I/\1u/;s/([üö][^V]*V)I/\1ü/;s/([aıou][^V]*V)E/\1a/;s/(V[^aEI][^V]*V)E/\1e/;t l
s/V//g'
Like my answer to the closely-related Dactylic Hexameter question, this is really just translating the rules as given into regular expressions.
Usage:
Takes input in the form:
word [01] [123] [123]
So the test cases are:
printf 'gütmek 0 1 2
almak 1 3 3
boğmak 1 2 1
ölmek 0 3 1
boyamak 1 1 2
affetmek 0 2 1
söylemek 1 3 1
söylemek 0 3 2
söylemek 0 1 3' | sed -E '<...>';
Breakdown:
sed -E "
# special cases for simple present tense
s/^((bul|dur|k?al|ol|san|v[au]r)ma|(bil|gel|gör|öl|ver)me)k( . .) 1/\2\3Ir\4/;
# stemming
# always uses -er rule if simple present
s/etmek( . .) 1/edEr\1/;
s/etmek /ed /;
s/^((ta)tma|([dg]i|gü)tme)k /\2\3d /;
s/m[ae]k / /;
# mark vowels for easier expressions later
s/([aıoueiöüEI])/V\1/g;
# simple present
s/(V.)( . .) 1/\1r\2/;
s/(V.+V.+)( . .) 1/\1VIr\2/;
s/( . .) 1/VEr\1/;
# continuing present
s/(V.)?( . .) 2/VIyVor\2/;
# future
s/(V.)( . . 3)/\1y\2/;
s/( . .) 3/VEcVEk\1/;
# personal suffix
s/k( . 1)/ğ\1/;
s/ 0 1/VIm/;
s/ 1 1/VIz/;
s/ 0 2/sVIn/;
s/ 1 2/sVInVIz/;
s/ 0 3//;
s/ 1 3/lVEr/;
# vowel harmony
:l
s/([ıa][^V]*V)I/\1ı/;
s/([ie][^V]*V)I/\1i/;
s/([uo][^V]*V)I/\1u/;
s/([üö][^V]*V)I/\1ü/;
s/([aıou][^V]*V)E/\1a/;
s/(V[^aEI][^V]*V)E/\1e/;
# keep looping until all vowels are known
t l
# unmark vowels
s/V//g
"
Results for test cases:
güdüyorum
alacaklar
boğarsınız
ölür
boyuyoruz
affedersin
söylerler
söylüyor
söyleyeceğim