[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Jun 8 08:36:58 2001 
Subject:Re: ? text-processing examples 
From:cglur 
Volume-ID:1010608.01 

(Aaron Sloman) wrote: 
---- snip ---
>     vars procedure(char_rep, item_rep);
>         ;;; declare them as procedure identifiers for efficiency.
> 
>     discin('myfile.txt') -> char_rep;
> 
>     incharitem(char_rep) -> item_rep;
> 
> Then char_rep is a procedure which, each time it is called returns the
> next character from the file myfile.txt ....
My manual/single-step call to discin apparently re-initialises.
ie. repeated reading of the *first* byte.
Apparently the 'counters' of repeaters are not global/persistent.
Within a single invocation (as per code below) the stepping is observed.
OK, since there is no initialisation code for discin: it must be auto-initialised
on 'start-run' ?

---- snip ---
> 
> It's going to be hard to know what to point you at unless you can
> be a bit more specific about some of the things you might want to
> do.
Well, my initial polog experiments overly impressed me until I realised
that elements of: [man in boat] ; are tokens (items for poplog), and NOT
'text-strings'. Unfortunately, human knowledge is embedded in text-strings.
This 'natural stuff', (which I've warned we shouldn't follow as we don't
follow flapping and feathers to advance aircraft design) has to be handled.
   So the abundant dirty-natural-text needs to be cleaned-up/formalised
to be processed to add value. I'm not much interested/optimistic about
natural language analysis, but favour man-machine co-operation.  

I want to be able to read text files from various sources/css/formats,
with some guidance/assistance from string-search facilities.  
And manually extract text-sections to various different holders/files; 
ie. use human evaluation.  

Modifying the code below, I was not able to send the alternate (to file 
'testout') text strings to screen. 
     char =>   ;;; produces <numeric value of char> 

How would I split a text string eg:
 			if char > 128 then consume(char)  ;;; post to non-ascii file
 			else  <write to screen> 
     		endif;

My substantial search (which, for the first time got me to the primer), fails
to show me how the write a character to screen.

 
> 	define transform_file(inputfile, outputfile);
> 		lvars
> 			produce = discin(inputfile),
> 			consume = discout(outputfile),
> 			char;
> 
> 		repeat
> 			produce() -> char;
> 			quitif (char == termin);
> 			if char < 128 then consume(char)
> 			else
> 				;;; whatever you want to go out, e.g. nothing,
> 				;;; or some translation
> 			endif;
> 		endrepeat;
> 		consume(termin); 	;;; to flush output buffer
> 	enddefine;
> 
> Then
> 	transform_file('testin', 'testout');
> 
> will read the file called 'testin' and write the transformed
> version to 'testout'. 
All this automagically behind the scene eg. opening and closing files, is
frightening to me .  
Apparently that's what hi-level programming is about ?

--- snip ---
> I hope that helps and is not too overwhelming.
A bit of both: no pain, no gain.

Thanks,
  Chris Glur.