1
votes

I have the following lexicon rules

gr_noun_suffix(masculine,singular,nominative,10,'ος').
gr_noun_suffix(masculine,singular,nominative,10,'ης').
gr_noun_suffix(masculine,singular,possessive,10,'η').
gr_noun_suffix(masculine,singular,accusative,10,'η').
gr_noun_suffix(masculine,plural,nominative,10,'ες').
gr_noun_suffix(masculine,plural,possessive,10,'ων').
gr_noun_suffix(masculine,plural,accusative,10,'ες').

and i need to give as input for example

gr_noun(X,F,Gender,Plurality,Singularity,Case,Code,[σκυλος],[]).

and get

F = σκυλ(X),
Gender= masculine,
Singularity= singular,
Case= possessive,
Code= 10 .

In other words i need the last syllable of the word broken, and compared to the rules, in order to fond what applies.

I seem to be stuck on how to break the last syllable of the word.

1
@RobertBaron For atoms and SWI-Prolog strings there are sub_atom/5 and sub_string/5 that can be used to enumerate substrings, prefixes, suffixes, etc.User9213

1 Answers

0
votes

Don't split atoms into lists of characters. Use sub_atom/5 to find the suffix or break it off.

I cannot understand what all the arguments are supposed to be, but this should be enough for a starting point:

gr_noun(X, F, Gender, Singularity, Case, Code, Noun) :-
    gr_noun_suffix(Gender, Singularity, Case, Code, X),
    sub_atom(Noun, Before, Len, 0, X),
    sub_atom(Noun, 0, Before, Len, F0),
    F =.. [F0, X].

With this I get:

?- gr_noun(X, F, Gender, Singularity, Case, Code, σκυλος).
X = ος,
F = σκυλ(ος),
Gender = masculine,
Singularity = singular,
Case = nominative,
Code = 10 ;