请帮帮我。我在Visual Prolog中编写了一个程序,将单词分为音节。我必须发布的最后一个谓词是用自由音节划分单词。我有一个带有声音 - 辅音声音的谓词,用于排除名字,责备,精细等等的字样。因此,我的程序将名称划分为na-me,这是错误的解决方案。当我添加所需的除法谓词时,程序忽略了它。如何为开放和闭合音节编写两个类似的谓词? 谢谢。
DOMAINS
letter = char
word_ = letter*
PREDICATES
divide(word_,word_,word_,word_)
vocal(letter)
unvocal(letter)
consonant(letter)
string_word(string,word_)
append(word_,word_,word_)
CLAUSES
divide(Start,[T1,T2,T3|Rest],D,[_|Rest]):-
vocal(T1),consonant(T2),unvocal(T3),
append(Start,[T1,T2,T3],D).
divide(Start,[T1,T2|Rest],D1,[T2|Rest]):-
vocal(T1),vocal(T2),
append(Start,[T1],D1).
divide(Start,[T1,T2,T3,T4,T5|Rest],D1,[T3,T4,T5|Rest]):-
vocal(T1),consonant(T2), consonant(T3), consonant(T4),vocal(T5),
append(Start,[T1,T2],D1).
divide(Start,[T1,T2,T3|Rest],D1,[T2,T3|Rest]):-
vocal(T1),consonant(T2),vocal(T3),
append(Start,[T1],D1).
divide(Start,[T1,T2,T3,T4|Rest],D1,[T3,T4|Rest]):-
vocal(T1),consonant(T2),consonant(T3),vocal(T4),
append(Start,[T1,T2],D1).
divide(Start,[T1|Rest],D1,D2):-
append(Start,[T1],S),
divide(S,Rest,D1,D2).
unvocal('e').
vocal('a'). vocal('e'). vocal('i').
vocal('o'). vocal('u'). vocal('y').
consonant(B):-
not(vocal(B),unvocal(B)).
string_word("",[]):-!.
string_word(Str,[H|T]):-
bound(Str),frontchar(Str,H,S),string_word(S,T).
string_word(Str,[H|T]):-
free(Str),bound(H),string_word(S,T),frontchar(Str,H,S).
append([],L,L):-!.
append([X|L1],L2,[X|L3]):-
append(L1,L2,L3).
GOAL
write("Write a multi-syllable word: "),
readln(S),nl,
string_word(S,Word),
divide([],Word,Part1,Part2),
string_word(Syllable1,Part1),
string_word(Syllable2,Part2),
write("Division: ",Syllable1,"-",Syllable2),nl,
fail.