[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [seul-edu] Crosswords basic generator released



El Dom 13 Ene 2002 03:02, escribió:
> Hi,
>
> > another script, let's see, if this re-release of the script gathers
> > attention or not.
>
> I've tried it out, but since it's spanish, I can't make sense of it.
> Python isn't my language either... Sorry,
>

Well, as a matter of fact, you don't need it to know either Python, 
either Spanish, it can be considered a "black box", a module, in fact in 
crosswords.50g.com,  it's quite isolated from the rest of modules.  
What you really need to know is :
a) How to run it: "python genaut.py"
b) Parse the output to your favourite "presentation" layout. For that, you 
only have to write the output into a file "python genaut.py > file" or copying
and pasting , and then do the parse of that file. So, if the output is :



- - - - - - - - - - - - - - -
- - - - - - - - - - - - - g -
- - - - d i s c i p l i n a -
- - - - - - - - - - l - - t -
- - - c o n f u s i o n - e -
- - - - r - - - - - r - - r -
- - - - d - p - - - o - - i -
- e m b e l e c o - - - - a -
- - - - n - s - - - - - - - -
- - - - - - a e r e o - - - -
- - - - - - r - i - - - - - -
- - - - - - - - s o l f a - -
- - - - - - - - a - i - - - -
- - - - - - - - - - o - - - -
- - - - - - - - - - - - - - -
(2, 14) DOWN gateria
(3, 5) ACROSS disciplina
(3, 11) DOWN lloro
(5, 4) ACROSS confusion
(5, 5) DOWN orden
(8, 2) ACROSS embeleco
(7, 7) DOWN pesar
(10, 7) ACROSS aereo
(10, 9) DOWN risa
(12, 9) ACROSS solfa
(12, 11) DOWN lio

You only have to create the appropiate regexp's or reading each character of 
each line  and storing it into a program in TCL, Perl, Ruby, C, Lisp or 
prolog.  The last part is to use that stored data to generate a javascript 
program, a HTML-CGI page, a KDE C program, a bash shell program, a emacs lisp 
program or simply generating text to be printed with the words in the 
crosswords being replaced by X, so you can it hand out in your classes. 
So, genaut.py can be considered a black box, of course, if you know python ( 
I think that you can modify it even if you don't speak Spanish, since the 
average function is only 5 lines long and you can guess out pretty well 
what's going on in each function), then you can tune it a bit. 

For example to get a printout version, that is, something that is going to be 
printed and handed out to your students just use this program in python:

def printout_Solution_Page(file, lines):
  f = open(file, "w")  
  for i in lines:
    if i[0] == '-':
     f.write(i)
  f.close()

def printout_Student_Page(file, lines):
  f = open(file, "w")
  for i in lines:
   if i[0] != '-':
     f.write(i)
   else:
     for j in i[:-1]:
      if j ==' ': continue
      if j=='-' :
        print "-",  
        f.write("-")
      else:
        print " ",
        f.write(" ")
     print 
     f.write("\n") 
  f.close()

nm1 ="name_of_file_where_you_have_stored_the_above_crossword"
nm2 ="File of Solution"
nm3 ="File of Sutdent Page"

nm1= "a"
nm2= "b"
nm3= "c"

f = open(nm1, "r")
l = f.readlines()
f.close()
printout_Solution_Page(nm2, l)
printout_Student_Page(nm3, l)


---- 
This programm has been tested, let me know if it's useful or you like the 
idea, to include it in the webpage or announcing in freshmeat. 


-------
MGA