Re: help with parsing and dcg (swi-prolog in particular)
- From: "Brian Hulley" <brianh@xxxxxxxxxxxx>
- Date: 21 May 2005 00:42:15 -0700
blindsearch wrote:
> I don't think a single list could handle it. The file I was reading
in
> was 2.5mb, there were 8199 frames.
The size of a list is only limited by the virtual memory of the
machine. I think you can use up to about 100Mb in each of the areas
(code/stack etc) in SWI Prolog so you might be able to get away with a
single list. (I think your file would only take up about 2.5 * 8 = 20Mb
but this is just a guess - you'll probably need to increase the size of
some memory areas - ?- apropos(memory). to find out more...)
Another way is to manually split the source file into smaller chunks.
> A frame is a concept (see my first message). I would like to be able
> write some dcg like
>
> concept -->
> [ (] concept_name concept_attributes ])].
>
> concept_name --> % a string.
>
> concept_attributes -->
> concept_attribute concept_attributes.
>
> concept_attribute -->
> [(] attribute_name [(] type stuff [)] [ )]
>
> etc.
>
> Now, I'm wondering too, how would I even parse it to a prolog list?
?- apropos(dcg). % good example here of parsing an integer...
On way is to start from the terminal tokens, writing some rules for
each, then gradually work upwards to the full frame syntax, and also
make a test file containing just one or two frames so you don't need to
bother about the possible limitations on memory sizes etc at this
stage.
If there was a real problem with list sizes, and you know that a frame
is at most 50K for example, you could write a predicate to just read
50K worth of chars, parse one concept from the start of it, then
assert/write out the result, assert the position in the file that you
parsed up to, then fail and restart from that position next time by
seeking... (but I wouldn't bother trying this until you know you can
parse a single frame from a small test file with good results)
Best regards, Brian.
.
- Follow-Ups:
- Re: help with parsing and dcg (swi-prolog in particular)
- From: Brian Hulley
- Re: help with parsing and dcg (swi-prolog in particular)
- References:
- help with parsing and dcg (swi-prolog in particular)
- From: blindsearch
- Re: help with parsing and dcg (swi-prolog in particular)
- From: Brian Hulley
- Re: help with parsing and dcg (swi-prolog in particular)
- From: blindsearch
- help with parsing and dcg (swi-prolog in particular)
- Prev by Date: Re: deductive databases
- Next by Date: Re: help with parsing and dcg (swi-prolog in particular)
- Previous by thread: Re: help with parsing and dcg (swi-prolog in particular)
- Next by thread: Re: help with parsing and dcg (swi-prolog in particular)
- Index(es):