home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / prolog / 2316 < prev    next >
Encoding:
Internet Message Format  |  1993-01-05  |  1.6 KB

  1. Path: sparky!uunet!pipex!bnr.co.uk!uknet!edcastle!aiai!ken
  2. From: ken@aiai.ed.ac.uk (Ken Johnson)
  3. Newsgroups: comp.lang.prolog
  4. Subject: Re: How to parse "I say: 'I love you'" to [I, say, I love you]
  5. Message-ID: <8085@skye.ed.ac.uk>
  6. Date: 5 Jan 93 11:08:51 GMT
  7. References: <1i97a9INN8h@sol.deakin.OZ.AU>
  8. Followup-To: comp.lang.prolog
  9. Organization: William's Wonderful Wonky Widget Warehouse
  10. Lines: 37
  11.  
  12.  
  13. In article <1i97a9INN8h@sol.deakin.OZ.AU> huang@deakin.OZ.AU (Weiguang
  14. Huang) writes:
  15.  
  16. # but how to parse to ["I", "say", "I love you"] ?
  17.  
  18. The following will do what you want, but I don't think what you describe
  19. is really what you want to do.  Instead of a list, you should really
  20. generate a term expressing the structure of the original, so [I, say, I,
  21. love, you] should really parse to a term such as
  22.  
  23.    say('I',love('I',you)).
  24.  
  25.  
  26. report([P,V|St]) --> pronoun(P), verb(V), quotation(St).
  27.  
  28. quotation([P1,V,P2]) --> pronoun(P1), verb(V), pronoun(P2).
  29.  
  30. pronoun('I') --> ['I'].
  31. pronoun(you) --> [you].
  32.  
  33. verb(say) --> [say].
  34. verb(love) --> [love].
  35.  
  36. This is how it works:
  37.  
  38. ?-  phrase(report(R),['I',say,'I',love,you]).
  39.  
  40.      R=[I,say,I,love,you]
  41.  
  42.  
  43.  
  44. -- 
  45. Son, all the pretty, intelligent,      || Ken Johnson                           healthy young women are taken.         || A I Applications Institute
  46. It's a basic rule of the universe,     || 80 South Bridge                       and if you don't like it,              || Edinburgh,  Scotland   EH1 1HN
  47. go somewhere else.                     || Phone 031-650 2756   Fax 031-650 6513
  48.                -- my dad  1906-1992    || E-mail ken@aiai.ed.ac.uk
  49.