2

i'm trying to write a program that translate a prolog sentence to a formal english sentence. here is my code :

sentence --> [if],[the], first_phrase, second_phrase.
first_phrase -->  predicate, det , assertion, det, noun.
second_phrase --> [then],[the], predicate, det , noun.
assertion --> noun, [and], [the], predicate.
det --> [are].
det --> [is].



noun --> [flat].
noun --> [webbed].
noun -->[waterfowl].
predicate --> [feet].
predicate --> [bill].
predicate -->[order].


sentence(S1,S3) :- first_phrase(S1,S2), second_phrase(S2,S3).
first_phrase(S1,S3) :- second_phrase(S1,S2), noun(S2,S3).
second_phrase(S1,S3) :- assertion(S1,S2), first_phrase(S2,S3).
det([is|X], X).
det([are|X], X).

the output of this code is like the following : X = [if, the, feet, are, flat, and, the, feet, are|…] so it's missing some words, where it should display some thing like this : If the feet are webbed and the bill is flat then the order is waterfowl.

what should i add or fix in order to get this result ?

false
  • 10,264
  • 13
  • 101
  • 209
Muhsag
  • 155
  • 3
  • 11

1 Answers1

0

Add this code to your source code file:

remove_max_depth:-
    current_prolog_flag(toplevel_print_options,Options),
    select(max_depth(_), Options, NOptions)->
    set_prolog_flag(toplevel_print_options, NOptions); true.

:-remove_max_depth.

Procedure remove_max_depth will remove the constraint over the maximum number of items to show on top level, and directive :-remove_max_depth. will execute the procedure when you consult the file.

gusbro
  • 22,357
  • 35
  • 46