I want to make an Arabic morphological analyzer using Prolog.
I have implemented the following code.
check(ي,1,male).
check(ت,1,female).
check(ا,1,me).
dict(لعب,3).
ending('',0,single).
ending(ون,2,plur).
parse([]).
parse(Word,Gender,Verb,Plurality):-
sub_atom(Word,0,LenHead,_,FirstCut),
check(FirstCut,LenHead,Gender),
sub_atom(Word,LenHead,_,LenAfter,Verb),
dict(Verb,LenOfVerb),
Location is LenHead+LenOfVerb,
sub_atom(Word,Location,LenAfter,_,EndOfWord),
ending(EndOfWord,_,Plurality).
Called with:
parse(يلعب,A,S,D).
Expectation:
A = male
S = لعب
D = single
Explanation of the code:
He must parse the word يلعب, note that in Arabic ي (the first letter on the right) indicates that it is a masculine word. And لعب is a verb.
Error:
When I run the code, I get the following error: ERROR: parse / 4: Undefined procedure: dict / 2
Please note that when copying an Arabic word using English letters, the code behaves as expected and does not cause this error.
How can I resolve this error or make Prolog understand the words R-to-L?
Edit:
, ي . , , , , .
