home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 9 / 09.iso / l / l217 / 2.ddi / EXAMPLES / CH13EX05.PRO < prev    next >
Encoding:
Prolog Source  |  1990-03-26  |  1.2 KB  |  62 lines

  1. /*
  2.    Copyright (c) 1986, 90 by Prolog Development Center
  3. */
  4.    
  5. domains
  6.    sentence    = s(noun_phrase,verb_phrase)
  7.  
  8.    noun_phrase = noun(noun) ; noun_phrase(detrm,noun)
  9.    noun        = string
  10.  
  11.    verb_phrase = verb(verb) ; verb_phrase(verb,noun_phrase)
  12.    verb        = string
  13.  
  14.    detrm       = string
  15.  
  16. predicates
  17.     s_sentence(string,sentence)
  18.     s_noun_phrase(string,string,noun_phrase)
  19.     s_verb_phrase(string,verb_phrase)
  20.     d(string)
  21.     n(string)
  22.     v(string)
  23.  
  24. clauses
  25.    s_sentence(Str, s(N_Phrase,V_Phrase) ):-
  26.       s_noun_phrase(Str, Rest, N_Phrase),
  27.       s_verb_phrase(Rest, V_Phrase).
  28.  
  29.   s_noun_phrase(Str, Rest, noun_phrase(Detr,Noun)):-
  30.       fronttoken(Str,Detr,Rest1),
  31.       d(Detr),
  32.       fronttoken(Rest1,Noun,Rest),
  33.       n(Noun).
  34.  
  35.   s_noun_phrase(Str,Rest,noun(Noun)):-
  36.       fronttoken(STR,Noun,Rest),
  37.       n(Noun).
  38.  
  39.   s_verb_phrase(Str, verb_phrase(Verb,N_Phrase)):-
  40.       fronttoken(Str,Verb,Rest1),
  41.       v(Verb),
  42.       s_noun_phrase(Rest1,"",N_Phrase).
  43.  
  44.   s_verb_phrase(Str,verb(Verb)):-
  45.       fronttoken(STR,Verb,""),
  46.       v(Verb).
  47.  
  48. /* determiner */
  49.  
  50.    d("the").
  51.    d("a").
  52.  
  53. /* nouns */
  54.  
  55.    n("bill").
  56.    n("dog").
  57.    n("cat").
  58.  
  59. /* verbs */
  60.  
  61.    v("is").
  62.