Reputation: 1
I'm trying to write some rule in prolog language to change singular form to plural form and want to support to write the rule.
Upvotes: -1
Views: 553
Reputation: 95
You can have a look on this book "Natural Language Processing for PROLOG Programmers" (Page 262-263) that describes some rules for changing singular form of a word to plural. I have written a simple program that works for nouns. I hope it helps.
morphology(W, Wo):-
(sub_atom(W,_, 2, 0, C), (C == sh; C = ch));
(sub_atom(W,_,1,0,P), (P == s; P == z; P == x)) ->
atom_concat(W,es,Wo) ;
(sub_atom(W,Q,1,0,L), (L == y)) ->
sub_atom(W,_,Q,1,L1), atom_concat(L1,ies,Wo) ;
atom_concat(W,s,Wo).
? morphology('Age', S).
S = 'Ages'.
? morphology(student, S).
S = students.
Upvotes: 0
Reputation: 1
list_member(X,[X|_]).
list_member(X,[_|TALL]):-list_member(X,TALL).
isVowels(A):-list_member(A,[a, e, i, o, u]),!.
isConsonants(A):-list_member(A,[b, c, d, f, g, h, j, k, l, m, n, p, q, r, s, t, v, x, w,y,z]),!.
word:- write('Enter the word you want to know weather it followed by a an or the:.'),read(X),nl,
plular(X):-((isVowels(sub_atom(X, _, 1, 0, C)))->(write('Plular form of '),write(X),write(' is '),write(X),write('s'));(write('Plular form of '),write(X),write(' is '),write(X),write('es'))).
Upvotes: 0
Reputation: 22803
I assume you want to pluralize English words. One approach is to have a general rule and also some specific rules for special cases.
% special cases
pluralize(deer, deer).
pluralize(mouse, mice).
pluralize(antenna, antennae).
% general rule
pluralize(Singular, Plural) :- atom_concat(Singular, s, Plural).
This seems to be OK for some words:
?- pluralize(coin, X).
X = coins.
?- pluralize(date, X).
X = dates.
But some words seem to trip it up:
?- pluralize(fox, X).
X = foxs.
You could probably make the rule more intelligent. This is where I'd start.
Upvotes: 0