-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.pl
72 lines (61 loc) · 1.74 KB
/
main.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* My humble endeavor to systematize the Kyrgyz morphology via Prolog.
*/
% Tracking down all vowels in a word via vowels/2: vowels(?Word, -Vowels)
vowels([], []).
vowels([V|T], [V|X]) :-
vowel(V),
vowels(T, X),
!.
vowels([C|T], X) :-
cons(C),
vowels(T, X).
% Finding the last vowel in [word] via last_vowel/2: last_vowel(?Vowels, ?Vowel)
last_vowel(S, X) :-
last(S, S1),
string_chars(S1, L),
vowels(L, V),
last(V, X).
last_letter(S, X) :-
last(S, S1),
string_chars(S1, L),
last(L, X).
start_with(S, X) :-
last(S, S1),
string_chars(S1, L),
nth0(0, L, X).
replace([_|T], 0, X, [X|T]).
replace([H|T], I, X, [H|R]) :-
I1 is I - 1,
replace(T, I1, X, R).
generate_inflection(S1, S3, Word) :-
noun(S1, Suffix), % S1 = [баш, тын], Suffix = [тын]
suffix(Suffix, S3), % S3 = []
append(Noun, Suffix, S1), % Noun = [баш]
last_vowel(Noun, NounLastVowel), % NounLastVowel = а
last_vowel(Suffix, SuffixLastVowel), % SuffixLastVowel = ы
harmony(NounLastVowel, SuffixLastVowel), % true
last_letter(Noun, NountLastLetter), % NountLastLetter = ш
start_with(Suffix, SuffixFirstLetter), % SuffixFirstLetter = т
agreement(NountLastLetter, SuffixFirstLetter),
atomic_list_concat(S1, '', Word).
generate_form(W, R) :-
convert_word_to_list(W, LW),
append(LW, _, X),
generate_inflection(X, [], R),
!.
convert_word_to_list(W, L) :-
last(L, W),
!.
noun --> ['кеме'].
%noun --> ['аба'].
%noun --> ['челек'].
%noun --> ['кол'].
%noun --> ['баш'].
%noun --> ['туз'].
%noun --> ['көз'].
%noun --> ['кой'].
%noun --> ['мерген'].
%noun --> ['балык'].
%noun --> ['сүрөт'].
% generate_inflection(_, [], W).