나는 프롤로그에서 자연어 구문 분석 작업을 설정했습니다. 지금까지 나는 어느 정도 프로그램을 작동 시켰습니다. 지금까지 [the,cat,sat,on,the,mat]
의 목록을 입력하면 sentence(noun_phrase(det(the), np2(noun(cat))), verb_phrase(verb(sat), pp(prep(on), noun_phrase(det(the), np2(noun(mat))))))
이 인쇄됩니다.프롤로그 구조에서 단어를 추출
내가해야 할 일은 명사구의 명사, 동사구의 동사 및 동사구의 명사를 추출하여 문장에서 키워드를 추출하는 것입니다. 목록을 반환 할 수 있습니다. [cat, sat, mat]. 메신저가 이걸로 막혀 있기 때문에 아무도 나에게 손을 내주지 못했을까요? 감사!
내 현재 코드는 다음과 같습니다
sentence(S,sentence((NP), (VP))):-
nl,
np(S, NP, R),
vp(R, VP, []),
write('sentence('), nl, write(' '), write((NP))
,nl,write(' '), write((VP)),nl,write(' ').
np([X | S], noun_phrase(det(X), NP2), R) :-
det(X),
np2(S, NP2, R).
np(S, NP, R) :-
np2(S, NP, R).
np(S, np(NP, PP), R) :-
append(X, Y, S), /* Changed here - otherwise possible endless recursion */
pp(Y, PP, R),
np(X, NP, []).
np2([X | R], np2(noun(X)), R) :-
noun(X).
np2([X | S], np2(adj(X), NP), R) :-
adj(X),
np2(S, NP, R).
pp([X | S], pp(prep(X), NP), R):-
prep(X),
np(S, NP, R).
vp([X | R], verb_phrase(verb(X)), R) :- /* Changed here - added the third argument */
verb(X).
vp([X | S], verb_phrase(verb(X), PP), R) :-
verb(X),
pp(S, PP, R).
vp([X | S], verb_phrase(verb(X), NP), R) :-
verb(X),
np(S, NP, R).
det(the).
det(with).
noun(cat).
noun(mat).
verb(sat).
prep(on).
adj(big).
, 감사합니다. 그러나 나는 오히려 시간이 문제이기 때문에 나는 이미 가지고있는 것의 표기법을 바꾸지 않을 것이다. ( – MartinM