1

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.

user13
  • 87
  • 1
  • 6
  • See [SWI-Prolog: splitting text atom into list of characters](https://stackoverflow.com/questions/31478457/swi-prolog-splitting-text-atom-into-list-of-characters). It should get you started. – RobertBaron May 24 '19 at 23:27
  • @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 May 25 '19 at 09:37

1 Answers1

0

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 ;
User9213
  • 1,316
  • 6
  • 12