home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / prolog / 2418 < prev    next >
Encoding:
Internet Message Format  |  1993-01-21  |  3.6 KB

  1. Path: sparky!uunet!spool.mu.edu!enterpoop.mit.edu!eru.mt.luth.se!lunic!sunic!news.funet.fi!funic!nokia.fi!ntc02.tele.nokia.fi!larsson
  2. From: larsson@ntc02.tele.nokia.fi
  3. Newsgroups: comp.lang.prolog
  4. Subject: Reading text files (continued)
  5. Message-ID: <1993Jan21.211044.1@ntc02.tele.nokia.fi>
  6. Date: 21 Jan 93 19:10:44 GMT
  7. Sender: usenet@noknic.nokia.fi (USENET at noknic)
  8. Organization: Nokia Telecommunications.
  9. Lines: 76
  10. Nntp-Posting-Host: ntc02.tele.nokia.fi
  11.  
  12. This is a follow up to the previous question on
  13. reading text files in Prolog:
  14.  
  15. Dear Jamie,
  16.  
  17. Thanks for your reply, where you said:
  18.  
  19. >...     can
  20. >you read the text file sentence by sentence, and store each
  21. >sentence in a data structure before parsing?  
  22.  
  23. Yes, what I thougth of first was to read a sentence and assert
  24. it (or perhaps assertz it) as a list: something like 
  25.  
  26. sent(n,[this,is,a,sentence],additional_predicates_discribing_sent).
  27.  
  28. where n might be the number of the sentence in the actual text,
  29. the list would be the actual sentence as found in the text, and
  30. additional predicates would describe that very sentence on the 
  31. sentential and, preferably also, on the supersentential level.
  32.  
  33. Here I have two silly problems: 
  34.  
  35. 1) How would I be able to  keep track
  36. of my position in the file all the time? After I've read the
  37. first sentence, I should go on 'seeing' the same file, but reading
  38. the following sentence, etc, etc... (This, I thought was a typical 
  39. uninformed problem; that's why I suspected the whole thing would 
  40. be a FAQ.)
  41.  
  42. 2) No big texts can be stored as lists, because the storage space
  43. alloted to atoms is restricted in most implementations of Prolog.
  44. This leaves me with the solution to store in some 'string' format
  45. (which also seems to be non-standard among diifferent implementations),
  46. and the converting those strings to lists, when the parser needs them.
  47. What string format would be a) portable and b) wellbehaved in the
  48. sense of NOT causing a stack overflow error message at some stage
  49. in the process.
  50.  
  51. >Unless your parser
  52. >has to backtrack to a previous sentence, a possible solution
  53. >might be to have a top-level loop which reads in a sentence and
  54. >then does a standard parse of the sentence.
  55.  
  56. This is probably a good way to getting started. Later on, it
  57. should be possible to backtrack over several sentences and,
  58. eventually, over any strech of text of arbitrary length, which
  59. can be stored in the database. My work is strongly oriented
  60. towards translation (and writing), so I must learn to deal with
  61. entire texts.
  62.  
  63. >     Are you using DCGs to do the parsing?  That might create
  64. >problems, if the DCG package expects to read a file itself.
  65.  
  66. I would like to stick to DCGs as much as possible, because it's
  67. a clean formalism, which other linguists also seem to understand
  68. with VERY LITTLE additional study. However, DCGs are maybe NOT
  69. a more final solution; they certainly do confine the programmer to
  70. a specific way of parsing (left corner, top down). But I think
  71. this is an issue, which only can be addressed after I've gotten
  72. started and gained some experience.
  73.  
  74. By the way, I'm using ARity Prolog on a PC, so the size of the database
  75. per se would not be a problem. The vendor promises 2 Gbyte. The
  76. use of dedicated Arity methods would render the programs non-portable
  77. to other platforms; there is a need for portability at least to
  78. various shades of UNIX.
  79.  
  80. --Arne.
  81.  
  82. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  83. Arne Larsson            Nokia Telecommunications
  84. Translator            Transmission Systems, Customer Services
  85. larsson@ntc02.tele.nokia.fi    P.O. Box 12, SF-02611 Espoo, Finland
  86.                 Phone +358 0 5117476, Fax +358 0 51044287
  87. *-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
  88.