Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

First attempt at Rebol - 16 hours later

 [1/13] from: greg:schofield:iinet:au at: 23-Sep-2007 22:48


I am no programmer, as a quick glance here will tell: http://members.iinet.net.au/%7Egreg.schofield/rebol/Rebol start.zip GUIs proved beyond me, at least a good quarter or more of the 16 hours proved that. I have now got to the point however, where I need to use them. The script is messy, and even has redundant code in it (from failed experiements mostly). The aim is simple enough - take a text file of a book from OCR, or in the exmples given, from the Gutenberg project and mark them up. The problem is that it necessarily a human undertaking (relying on grep, or search and replace is hazardess - the source material is not reliable or consistent). The aim is to use carriage returns as suggested markers, but allow the user to group and identify parts of the books as chapters, sections, etc.,. For this it generates a map of patterns and from these the user needs to click on the map and see the text before selecting what shoud be done with it. The idea is to make a dialect in plain English which identifies what is to be done with what and when satisified that the description fits the work, then have it processed. REBOL's block series has been a blessing, it makes a lot of things easy (but I still have a lot to learn). If anyone has the time please run my script with the examples found in the zip. Any comment would be welcomed. I am an English teacher and need to produce textbooks cheaply and easily - the long term aim is to have texts taged in TEI XML and generate PDFs from there, for both screen and paper reading. At the moment I am doing it all by hand via OpenOffice - the script even as it now stands (incomplete) already saves me hours, if I can get it to the next stage, it should only take a few minutes to get it ready for layout at least. BTW learning a language from scratch and at least creating something half-useful is a big complement to just how good REBOL is, especially as I would probably spend less than 50 hours a year doing any form of scripting (REXX). Greg Schofield Perth Australia

 [2/13] from: anton:wilddsl:au at: 24-Sep-2007 2:00


Hi Greg, I've run your script, Cleanerxx.r. Some optimizations are definitely possible. I see the output character map. It seems to show the number of blank lines in between lines with content. I think I see where you're going with this. I'll have some more comments for you tomorrow. Regards, Anton.

 [3/13] from: gregg:pointillistic at: 23-Sep-2007 11:20


Sounds like a fun project Greg. I hope someone else has some free time to pitch in on it. Keep us posted on your progress; I've marked your message in case I come up with some free time. -- Gregg

 [4/13] from: anton::wilddsl::net::au at: 24-Sep-2007 4:42


Hi Greg, I have extensively (but not completely) optimized your Cleanerxx.r script. http://anton.wildit.net.au/Cleanerxx_anton.r (This link is temporary. I'll delete it after you get it.) It produces almost exactly the same map as yours, but a lot faster. (I tested only on 36.txt.) The script can be optimized much further, (I think a single parse can do it all.) but I wanted to show you the improvements in stages. I'm not sure exactly what the script should do and what modifications should be available to the user. Could you list those things ? eg: 1) Insert page break Replace selected <bnn> with <br/> 2) Make title Enclose selected text in <title> </title> Regards, Anton.

 [5/13] from: greg::schofield::iinet::net::au at: 24-Sep-2007 7:26


Anto, that was more than I was expecting from anyone and very kind of you. I will need to study the changes this afternoon to get my REBOL much improved. I know the script aims are very simple, and only useful for a very restrictive need. In the end I will make it publically available (if it is up to scratch), so at least teachers can convert HTML and plain text literature into more useful forms. "1) Insert page break Replace selected <bnn> with <br/>" "2) Make title Enclose selected text in <title> </title>" And yes this is primary objective, just give the text structural shape so that it can be more easily handled (<div> being most important - chapters having beginings and ends etc). The problems with all XMLeditrors I have used is that they assume you are inputing the text into tags, when in fact for such things you need to structure the text with tags. They just don't work for large works - unless cutting and pasting hundreds of pages is seen as a good productive time (it isn't). Lines --> block series proved extremely useful (I have a huge amount to learn here), treating nested structures as flat ones and easy conversion to nested (I am just using a simple write to file, read from file mechanism to go between the two) looks like it could pull the thing together without special code (which is rather neat). Originally I was going to wait for R3, hopefully I will not have to unlearn much. The main reason I posted it, was to encourage REBOLers. The script was written literally with the manual in hand (the manual needs some reshaping - an index would have helped a great deal - maybe this is something I can help with in the future), and anyone can tell I am not a good programmer in any sense. The fact that I could get it working at all is a tribute to the ease and power of REBOL. Anton, I still canot believe you took so much trouble over my code piece. I am both grateful and in awe - thank you! Greg Schofield Perth Australia --- Message Received --- From: Anton Rolls <anton-wilddsl.net.au> To: rebolist-rebol.com Reply-To: rebolist-rebol.com Date: Mon, 24 Sep 2007 04:42:49 +1000 Subject: [REBOL] Re: First attempt at Rebol - 16 hours later Hi Greg, I have extensively (but not completely) optimized your Cleanerxx.r script. http://anton.wildit.net.au/Cleanerxx_anton.r (This link is temporary. I'll delete it after you get it.) It produces almost exactly the same map as yours, but a lot faster. (I tested only on 36.txt.) The script can be optimized much further, (I think a single parse can do it all.) but I wanted to show you the improvements in stages. I'm not sure exactly what the script should do and what modifications should be available to the user. Could you list those things ? eg: 1) Insert page break Replace selected <bnn> with <br/> 2) Make title Enclose selected text in <title> </title> Regards, Anton.

 [6/13] from: anton::wilddsl::net::au at: 24-Sep-2007 13:43


Hi Greg, Here is a mock GUI layout. window: layout [ across map-face: area 220x600 wrap font-name font-fixed ;(map) scroller 16x600 main-face: area 400x600 ;(read %emma11.txt) scroller 16x600 panel [ button "Load..." button "title" button "<div>" button "<br>" ] ] edit-book: func ["Opens a window to edit and markup text" 'text [file! string! word! paren! any-type!] ; any-type! to allow unset! (ie. no arg specified in command line) ][ ; handle 'text argument text: either value? 'text [:text][copy ""] ; convert unset to empty string if word? :text [text: any [all [string? get :text get :text] copy ""]] ; a word which evaluates to a string if file? text [text: read text] if paren? text [text: do text] if not string? text [text: copy ""] ; convert any other type to empty string main-face/text: text main-face/line-list: none ; Open window ;view/new layout [across map-face: area 200x600 area 400x600 (text)] view/new window ;<- Process text here, generate map etc. map-face/text: "-----------2-1---^/---- etc..." ; <-- mockup placeholder map for now... show map-face do-events ] ; Usage example
>> edit-book
You wrote:
> Anto, that was more than I was expecting from anyone and very kind of you > .
No worries, mate.
> I will need to study the changes this afternoon to get my REBOL much impr > oved. > > I know the script aims are very simple, and only useful for a very restri > ctive need.
The simpler the better.
> In the end I will make it publically available (if it is up to scratch), > so at least teachers can convert HTML and plain text literature into more
<<quoted lines omitted: 6>>
> that it can be more easily handled (<div> being most important - chapter > s having beginings and ends etc).
Any others?
> The problems with all XMLeditrors I have used is that they assume you are > inputing the text into tags, when in fact for such things you need to st > ructure the text with tags. They just don't work for large works - unles > s cutting and pasting hundreds of pages is seen as a good productive time > (it isn't).
I am the most important program in the world!
> Greg Schofield
Regards, Anton.

 [7/13] from: greg:schofield:iinet:au at: 26-Sep-2007 18:53


Anton, I did not want you to think I am rude. I am still trying to get my head around Layout activation, I am missing something simple and obvious. I can display the GUI, but not make them work. I am very impressed with what you have done with parse in making my script tighter, quicker, and easier to read. Parse is looking like my new best friend, it has changed my ideas on how to handle things. While Blocks are a whole lot more than a variation of stem variables (arrays) that I first took them for. All I can say is I like REBOL more and more, but there are some things I really have to understand a lot better than I do presently (hopefully not too much becoming redundant by R3). For those that are old hands newby problems may seem stupid, but there is, I think, a problem with documentation that needs attention in the future. The example tutorials are fine as they stand, but a more conceptual explanation is needed, I am hoping I might help, once I know enough, in writing one. Most of all I am enjoying the REBOL experience, I only wish I could spend more time playing with this wonderful and ever so flexible language. Anton, again thanks for your help, you have boosted me along much further along in my understanding than I expected. This is a very friendly community, thanks for all your help. Greg Schofield Perth Australia PS is anyone working on a Text To Speech engine for REBOL? Some of the voices available are very high quality these days and I use acelerated Voice Synthesis to teach students to read fast and accurately. --- Message Received --- From: Anton Rolls <anton-wilddsl.net.au> To: rebolist-rebol.com Reply-To: rebolist-rebol.com Date: Mon, 24 Sep 2007 13:43:04 +1000

 [8/13] from: david:may10:ntlworld at: 29-Sep-2007 23:21


Hello greg, Wednesday, September 26, 2007, 11:53:56 AM, you wrote:
> Anton, I did not want you to think I am rude. > I am still trying to get my head around Layout activation, I am missing s
<<quoted lines omitted: 29>>
> Date: Mon, 24 Sep 2007 13:43:04 +1000 > Subject: [REBOL] Re: First attempt at Rebol - 16 hours later
try this http://www.rebol.net/plugin/demos/new-demos/speak.html -- Best regards, david mailto:david.may10-ntlworld.com

 [9/13] from: carl:cybercraft at: 30-Sep-2007 13:20


On Wednesday, 26-September-2007 at 18:53:56 greg.schofield wrote,
>Anton, I did not want you to think I am rude. > >I am still trying to get my head around Layout activation, I am missing s >omething simple and obvious. I can display the GUI, but not make them wo >rk.
Hi Greg, By 'not making them work', what do you mean? (I tried Anton's example and while I couldn't get it to run by cutting and pasting it into the console, (even after I'd tidied up the wrapped lines), it did run after I'd turned it into a script. Not that I knew what to do with it then - but it was alive.) My general approach to layouts is to have a main layout from which other layouts can be opened (if required) using view/new. An example... ;-- Layouts... main-lo: layout [ text-box: area 400x200 across btn "Add Random Line" [add-line] btn "Open Second Window" [view/new second-lo] btn "Does nothing" btn "Does nothing too" [] ; Needs stuff in the block to do anything. return btn "Close all Windows" [unview/all] ] second-lo: layout [ banner "Hello REBOLs!!!" black btn "Close Me!" [unview/only second-lo] ] ;-- A function. add-line: func [ "Add a line of characters to the text in text-box and display it." ][ loop random 6 [append text-box/text random " qwertyuiop"] append text-box/text "^/" ; Add return character. show text-box ] ;-- Open main layout... view main-lo Note with this approach only one version of the second window can be opened at once, which is what you mostly want. View docs I'm afraid are all over the place. The official REBOL/Core guide (in book form and online) is very good, but there's never been a decent (or any?) book in English released for View, though Olivier Auverlot's French one is supposed to be very good. Hopefully it'll all be rectified when R3 leaves beta. Anyway, hope the above helps and don't be afraid to ask any questions here. It's what the list is for and REBOL sure needs more newbies! -- Carl Read.

 [10/13] from: greg:schofield:iinet:au at: 30-Sep-2007 11:38


Very kind of you Carl, For some reason my mail did not get through for days and since then I found some extra documetation on the GUI and have got things running. Anton's scripts have been heaven sent in terms of increasing my REBOL awareness. My only problem now is how to get a selection from a "area" and whether I can position "area" according to a line position. For long time I have been fiddling with LUA which is a fine language in its own right, but nothing compared to REBOL. Carl I have just read through your script. I think my main problem is not always seeing the relation between blocks clearly. I need to progress a few steps further before I can be clear about this, but it is something to do with blocks and words implying "sentences", when I tend to read them as different "commands" and get confused as to how the blocks relate to one another. I am using heavy handed comments at the moment to make things clear to me. With R3 it might be nice to have an editor which uses as an option alternate colours to make clear which blocks belong together syntactically. I think this may be a major newbie problem, but I am not sure yet. In terms of books they are certainly needed, and there needs to be a way to consolidate documentation. I keep find in losing important information, and then discovering bits by accident. The only other thing I would suggest with documentation is to make it so it can be downloaded coherently and usefully (I am going to look after my mother for a week, and not have internet access). The last is printing the documentation - PDF maker is a must and at least two forms are needed, one an open traditional layout, the other in a compressed form that saves paper. But thanks again Carl and everyone on the list. REBOL deserves a much wider audience, and has what is needed to make a big change in how things are done on computers. Greg Schofield Perth Australia --- Message Received --- From: Carl Read <carl-cybercraft.co.nz> To: rebolist-rebol.com Reply-To: rebolist-rebol.com Date: Sun, 30 Sep 2007 13:20:20 +1200 Subject: [REBOL] Re: First attempt at Rebol - 16 hours later On Wednesday, 26-September-2007 at 18:53:56 greg.schofield wrote,
>Anton, I did not want you to think I am rude. > >I am still trying to get my head around Layout activation, I am missing s >omething simple and obvious. I can display the GUI, but not make them wo >rk.
Hi Greg, By 'not making them work', what do you mean? (I tried Anton's example and while I couldn't get it to run by cutting and pasting it into the console, (even after I'd tidied up the wrapped lines), it did run after I'd turned it into a script. Not that I knew what to do with it then - but it was alive.) My general approach to layouts is to have a main layout from which other layouts can be opened (if required) using view/new. An example... ;-- Layouts... main-lo: layout [ text-box: area 400x200 across btn "Add Random Line" [add-line] btn "Open Second Window" [view/new second-lo] btn "Does nothing" btn "Does nothing too" [] ; Needs stuff in the block to do anything. return btn "Close all Windows" [unview/all] ] second-lo: layout [ banner "Hello REBOLs!!!" black btn "Close Me!" [unview/only second-lo] ] ;-- A function. add-line: func [ "Add a line of characters to the text in text-box and display it." ][ loop random 6 [append text-box/text random " qwertyuiop"] append text-box/text "^/" ; Add return character. show text-box ] ;-- Open main layout... view main-lo Note with this approach only one version of the second window can be opened at once, which is what you mostly want. View docs I'm afraid are all over the place. The official REBOL/Core guide (in book form and online) is very good, but there's never been a decent (or any?) book in English released for View, though Olivier Auverlot's French one is supposed to be very good. Hopefully it'll all be rectified when R3 leaves beta. Anyway, hope the above helps and don't be afraid to ask any questions here. It's what the list is for and REBOL sure needs more newbies! -- Carl Read.

 [11/13] from: carl:cybercraft at: 30-Sep-2007 9:51


On Sunday, 30-September-2007 at 11:38:39 greg.schofield wrote,
>Carl I have just read through your script. I think my main problem is not > always seeing the relation between blocks clearly. I need to progress a >few steps further before I can be clear about this, but it is something t >o do with blocks and words implying "sentences", when I tend to read them > as different "commands" and get confused as to how the blocks relate to >one another.
Layouts can be a bit confusing, since they're written in a dialect of REBOL, (known as VID), and so aren't standard REBOL. Thus we can have stuff like so... layout [b: btn "A Button" [do something when button is clicked] red] layout [b: btn [do something when button is clicked] "A Button" red] layout [b: btn red "A Button" [do something when button is clicked]] Those will all function the same, since when REBOL parses the layout it doesn't usually care about the order of what's after a style (BTN in this case.) In the BTN cases above, if it encounters a string, it will store that string in B/TEXT, a block will be stored somewhere else as it's assumed to contain standard REBOL code to be evaluated should the button be clicked, and RED (which is a tuple datatype which are used for colors) will be stored in its appropriate place. So a layout is best thought of as data, not sentences or code. They're parsed (from beginning to end and style to style, I assume), and end up as an object which VIEW (meaning the REBOL function) then uses to decide how a window will look and behave. In standard REBOL though, a block can be thought of as a container that's used when you need to store 2 or more values. An example...
>> blk: [a 1 b 2 c 3]
== [a 1 b 2 c 3]
>> foreach n blk [print n]
a 1 b 2 c 3
>> foreach [a b] blk [print a]
a b c
>> foreach [a b] blk [print b]
1 2 3
>> foreach [a b] blk [print [a b]]
a 1 b 2 c 3 With FOREACH and PRINT there, just by replacing words with blocks of words, they become more useful. (Obviously FOREACH and PRINT had to be written so they can handle such an option.) Now you can think of REBOL functions and the like as commands, but until they're evaluated, they're really just data. ie...
>> blk: [print 1 print 2 print 3]
== [print 1 print 2 print 3]
>> foreach [a b] blk [print [a b]]
print 1 print 2 print 3
>> do blk
1 2 3 In that case, the PRINTSs in BLK are just REBOL words with no meaning until the block they're in is evaluated by DO. Umm - I hope this has helped and not just confused you more! :-) -- Carl Read.

 [12/13] from: anton:wilddsl:au at: 4-Oct-2007 1:20


Hi Greg, Check out this script, which just does markup and makes a map, in good time. http://anton.wildit.net.au/temp/mark-up.r No solid idea for the GUI yet, but ideas are floating. Regards, Anton.

 [13/13] from: anton:wilddsl:au at: 4-Oct-2007 0:03


Actually, for this job, with lots of inserts/removes, it should be much faster to work with a block of lines, rather than parse the whole text in a single string, so use READ/LINES. Regards, Anton.

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted