Προς το περιεχόμενο

Prolog proggrammm-Orthografos,Help!


Sandman

Προτεινόμενες αναρτήσεις

Δημοσ.

Exw mia ergasia se prolog-orthografos-kai me exei paidepsei arketa.

Ayto pou zhtaei einai na dexetai mia protash ypo thn morfh listwn p.e.:

([[s,c,h,o,e,l],,[f,u,c,k,e,d,e],[u,p,]]).

kai na diorthwnei ta lathi twn lexewn dhladh:

([[s,c,h,o,o,l],[i,s],[f,u,c,k,e,d],[u,p]]).

oi lexeis einai periorismenes kai dinontai ypo morfh kathgorhmatwn:

word([s,c,h,o,o,l]).

word([i,s]).........

 

Kati tetoio peripou.

An kapoios mporei na vohthisei tha me swsei...?!

  • 2 εβδομάδες αργότερα...
Δημοσ.

ela re synadelfe tsimpa th lysh ths ergasias. an kai ligo arga alla den peirazei.....

 

% leksiko me tis sosta orthografika leksis.

word([t,h,e]).

word([m,a,n]).

word([a,n,d]).

word([r,e,d]).

word([w,o,m,a,n]).

word([h,e,l,l,o]).

 

 

 

 

 

% Gia thn periptwsh pou h leksi den exei lathos

% xrhsimopoioume to kathgorhma correct

 

correct([],[]).

correct([HEAD|TALE],[HEAD|TALE]):-correct(TALE,TALE).

 

 

 

 

% Periptwsi pou h lathos leksi exei elleipsh enos grammatos

 

missing_letter(Wrong_word,Correct_word):- %xwrizei th leksh se 2 ypolistes: (L1) kai (T1)

append(L1,T1,Wrong_word), %to gramma pou leipei (H1) mpainei endiamesa stis 2

word(Correct_word), %ypolistes

append(L1,[H1|T1],Correct_word).

 

 

 

% Periptwsi pou h lathos leksi exei ena gramma perissotero

 

more_letter(Wrong_word,Correct_word):- %dexetai 2 lekseis (listes) kai xwrizei thn 1h se 2 ypolistes

append(L1,[H1|T1],Wrong_word), %apo tis opoies h kefalh ths 2hs einai to gramma pou perisseyei

word(Correct_word), %kai to afairei

append(L1,T1,Correct_word).

 

 

% Periptwsi pou sth lathos leksh prepei na ginei antallagh 2 grammatwn

change_letters(Wrong_word,Correct_word):- %Dexetai 2 lekseis (listes) kai wxwrizei thn 1h se 2 ypolistes

append(L1,[H1|T1],Wrong_word), %apo tis opoies h kefalh tis 2hs einai to ena apo ta grammata

append(L2,[H2|T2],T1), %pou briskontai se lathos thesi(to 1o). H oura ths 2hs lekshs

word(Correct_word), %xwrizetai ki auth se 2 ypolistes pou h kefalh ths 2hs einai to

append(L1,[H2|T],Correct_word), %2o gramma se lathos thesi. Ta grammata allazoun thesi.

append(L2,[H1|T2],T).

 

%Periptwsi pou h leksi exei ena lathos

 

one_wrong_letter(Wrong_word,Correct_word):- %Dexetai 2 lekseis (listes) kai klassika xwrizei thn 1h se 2 ypolistes

append(L1,[H1|T1],Wrong_word), %pou h kefalh ths 2hs einai to lathos gramma. To diorthwnei.

word(Correct_word),

append(L1,[H2,T1],Correct-word).

 

 

 

 

% To basiko kathgorima 'orthpgrafos' pou xrisimopoiei ta epimerous kathgorhmaea gia kathe lathos

%kai diorthwnei thn protash

orthografos([],[]).

orthografos([Word|Rest1],[Corrected|Rest2]):-

missing_letter(Word,Corrected),

orthografos(Rest1,Rest2).

orthografos([Word|Rest1],[Corrected|Rest2]):-

more_letter(Word,Corrected),

orthografos(Rest1,Rest2).

orthografos([Word|Rest1],[Corrected|Rest2]):-

change_letters(Word,Corrected),

orthografos(Rest1,Rest2).

orthografos([Word|Rest1],[Corrected|Rest2]):-

one_wrong_letter(Word,Corrected),

orthografos(Rest1,Rest2).

  • 2 εβδομάδες αργότερα...

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...