Author Topic: Crossword Generator  (Read 11970 times)

0 Members and 1 Guest are viewing this topic.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #15 on: August 24, 2019, 06:00:06 am »
¿ñ's y ü's son muy raras en español, señor?  The only two words in Spanish that any Brit knows have the ñ!!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #16 on: August 24, 2019, 06:12:55 am »
Steve, thanks very much.  I knew that it would be something to do with Unicode and extended ASCII and maybe opening a file in BINARY instead of INPUT and I was just dabbling trying to get something going, but now I can work with what you've done.  If I get stuck (probable), I'll let you know.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #17 on: August 24, 2019, 07:33:19 am »
Steve, I've had a go with your code which seems to be nearly working (or probably working correctly, but I misunderstand).  By the way I've changed from a,i,n,o,e to a,e,i,o,u as those are the only ones which Petoro wants.  I find the following in a converted file:

For orignal word abaceriá (grocery), the code gives abaceri and loses the a.

I cannot see why the code would give this error, or maybe I'm misunderstanding the original file.

Petoro, would you confirm that abaceriá is the correct Spanish and not abaceri?  Thank you.

Offline petoro

  • Newbie
  • Posts: 27
    • View Profile
Re: Crossword Generator
« Reply #18 on: August 24, 2019, 07:35:14 am »
I think I have found a better Spanish dictionary here:

http://www.gwicks.net/dictionaries.htm

There is only one file. And YES, it contains conjugate verbs this time!

I think it is a little better formatted and tidy. Still it contains accented letters and ñ's, so it needs conversion. It is around 174 000 words long.

Thanks Steve, I'm giving a look at your program, not sure if it works the same way in Ubuntu and Windows...

Offline petoro

  • Newbie
  • Posts: 27
    • View Profile
Re: Crossword Generator
« Reply #19 on: August 24, 2019, 07:44:58 am »
Steve, I've had a go with your code which seems to be nearly working (or probably working correctly, but I misunderstand).  By the way I've changed from a,i,n,o,e to a,e,i,o,u as those are the only ones which Petoro wants.  I find the following in a converted file:

For orignal word abaceriá (grocery), the code gives abaceri and loses the a.

I cannot see why the code would give this error, or maybe I'm misunderstanding the original file.

Petoro, would you confirm that abaceriá is the correct Spanish and not abaceri?  Thank you.

Yes, I am having certain errors in Ubuntu. For example it translates abacería to abaceraa insted of abaceria, the later is correct. Or abrogacian instead of abrogacion.



Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Crossword Generator
« Reply #20 on: August 24, 2019, 07:55:24 am »
Yes, I am having certain errors in Ubuntu. For example it translates abacería to abaceraa insted of abaceria, the later is correct. Or abrogacian instead of abrogacion.

Did i get my letters backwards?  I was being lazy and just copy/pasted to enter the letters.  I may have entered them backwards...  I’ll doublecheck things in a bit; it’s almost breakfast time with the family here.
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline petoro

  • Newbie
  • Posts: 27
    • View Profile
Re: Crossword Generator
« Reply #21 on: August 24, 2019, 08:17:01 am »
¿ñ's y ü's son muy raras en español, señor?  The only two words in Spanish that any Brit knows have the ñ!!

Well ñ's are not so "raras", ü's are however.

Offline petoro

  • Newbie
  • Posts: 27
    • View Profile
Re: Crossword Generator
« Reply #22 on: August 24, 2019, 08:29:38 am »
Did i get my letters backwards?  I was being lazy and just copy/pasted to enter the letters.  I may have entered them backwards...  I’ll doublecheck things in a bit; it’s almost breakfast time with the family here.
Tryng to convert the new dictionary espanol.txt to espanol-converted.txt with your program.

Thank you for the code!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #23 on: August 24, 2019, 09:15:48 am »
I shall stop trying to deprive Petoro of some of the fun, as it looks as though Steve and Petoro can create the required text file.  So all I need is a text file with only a-z :- in alphabetical order with no duplicates would be preferable.

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Crossword Generator
« Reply #24 on: August 24, 2019, 01:36:56 pm »
I shall stop trying to deprive Petoro of some of the fun, as it looks as though Steve and Petoro can create the required text file.  So all I need is a text file with only a-z :- in alphabetical order with no duplicates would be preferable.

See if this little program won't do what you're wanting, with customization:

Code: QB64: [Select]
  1. SCREEN _NEWIMAGE(800, 600, 32)
  2. DIM ExemptionCode(1000) AS STRING * 2, Exempt AS INTEGER
  3. DIM ReplaceWhat(1000) AS STRING, ReplaceWith(1000) AS STRING, Replacements AS INTEGER
  4. _TITLE "Replace UniCode Project"
  5. file$ = "a.txt"
  6. out$ = "a-modified.txt"
  7.  
  8. OPEN file$ FOR BINARY AS #1 'Read in the old file
  9. OPEN out$ FOR BINARY AS #2 'And, the out file
  10.  
  11. IF LOF(1) = 0 THEN
  12.     FOR i = 1 TO 100
  13.         CLS
  14.         PRINT "No file, dummy!  I'm going to go format your computer now!"
  15.         PRINT
  16.         PRINT "Formatting in process."
  17.         X = _EXIT 'just to be mean! CAUSE!!
  18.         FOR j = 1 TO i
  19.             PRINT ".";
  20.         NEXT
  21.         _DELAY .1
  22.     NEXT
  23.     PRINT
  24.     PRINT
  25.     PRINT "I've now erased all your stuff, because you made me angry!"
  26.     FOR j = 1 TO 10
  27.         PRINT "Ha! ";
  28.         _DELAY 1
  29.     NEXT
  30.     SYSTEM
  31.  
  32.     LINE INPUT #1, text$
  33.     count = count + 1
  34.     CLS
  35.     redo:
  36.     'make all replacements that we've already established
  37.  
  38.     PRINT "AUTOMATIC REPLACEMENTS:"
  39.     FOR i = 1 TO Replacements
  40.         PRINT i; ")", ReplaceWhat(i), "with", ReplaceWith(i)
  41.         ReplaceAll text$, ReplaceWhat(i), ReplaceWith(i)
  42.     NEXT
  43.     PRINT
  44.     PRINT "CURRENTLY PROCESSING:"
  45.  
  46.     PRINT count; ")"; TAB(10); text$
  47.     bad = 0
  48.     FOR i = 1 TO LEN(text$)
  49.         a = ASC(text$, i)
  50.         IF a < 32 OR a > 128 THEN 'it's an extended character
  51.             test$ = MID$(text$, i, 2) 'look for our list of exemptions
  52.             FOR j = 1 TO Exempt
  53.                 IF test$ = ExemptionCode(j) THEN
  54.                     i = i + 1 'move past the second character as well
  55.                     _CONTINUE 'and check from this point on
  56.                 END IF
  57.             NEXT
  58.             bad = a 'Otherwise, see what to do with it
  59.             EXIT FOR
  60.         END IF
  61.     NEXT
  62.     IF bad THEN
  63.         PRINT "Non-Standard characters found. ("; test$; ")"
  64.         PRINT "Do you want to replace all these characters with something different? ";
  65.         DO
  66.             _LIMIT 10
  67.             a$ = UCASE$(INPUT$(1))
  68.         LOOP UNTIL a$ = "Y" OR a$ = "N"
  69.         PRINT a$
  70.         PRINT
  71.         IF a$ = "N" THEN
  72.             Exempt = Exempt + 1
  73.             ExemptionCode(Exempt) = MID$(text$, bad, 2)
  74.             GOTO redo 'check the word for more issues
  75.         ELSE
  76.             DO
  77.                 PRINT "Replaceing " + test$ + " with ";
  78.                 r$ = INPUT$(1)
  79.                 PRINT r$
  80.                 PRINT
  81.                 PRINT "Is this correct? (Y/N)"
  82.                 DO
  83.                     _LIMIT 10
  84.                     a$ = UCASE$(INPUT$(1))
  85.                 LOOP UNTIL a$ = "Y" OR a$ = "N"
  86.                 PRINT a$
  87.             LOOP UNTIL a$ = "Y"
  88.             Replacements = Replacements + 1
  89.             ReplaceWhat(Replacements) = test$
  90.             ReplaceWith(Replacements) = r$
  91.             GOTO redo 'replace and check the word for more issues.
  92.         END IF
  93.         PRINT
  94.     END IF
  95.     text$ = text$ + CHR$(10) 'unix line ending.  No need to use the CHR$(13) + chr$(10) since even notepad is dropping them.
  96.     PUT #2, , text$
  97.  
  98.  
  99. SUB ReplaceAll (text$, find$, replace$)
  100.     DO
  101.         l = INSTR(text$, find$)
  102.         IF l THEN
  103.             text$ = LEFT$(text$, l - 1) + replace$ + MID$(text$, l + LEN(find$) + 1)
  104.         END IF
  105.     LOOP UNTIL l = 0

If it works as I'm hoping it should for you, I'll share it in the programs forum, and folks can find it and make use of it for future conversion needs.  ;)
« Last Edit: August 29, 2019, 02:20:40 pm by SMcNeill »
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #25 on: August 25, 2019, 05:30:07 am »
Petoro, here is a Spanish version of the prgram.

Place all the files in .zip into the existing Crossword Generator folder (it will need the font file which is already there) and run the Crucigrama Generador bas.

It takes longer for the program to find a solution.  This is because there are so few letters which commonly end Spanish words.  It much be more challenging for Spaniards to create crosswords than for Britons.  But it still works.

spanishxword.jpg
* spanishxword.jpg (Filesize: 149.7 KB, Dimensions: 794x793, Views: 198)
* Crucigrama.zip (Filesize: 226.87 KB, Downloads: 173)
« Last Edit: August 25, 2019, 05:39:09 am by Qwerkey »

Offline petoro

  • Newbie
  • Posts: 27
    • View Profile
Re: Crossword Generator
« Reply #26 on: August 25, 2019, 07:50:45 am »
Thank you, it "invents" a new Spanish crucigrama from scratch in a very reasonable amount of time.

Besides, the words are not rather strange at all.

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #27 on: August 25, 2019, 09:42:05 am »
Version 2

14/9/19: Version 2 has been superseded by a general update to the program - see first part of post.
« Last Edit: September 14, 2019, 03:43:36 am by Qwerkey »

Offline ExilePrisoner

  • Newbie
  • Posts: 6
    • View Profile
Re: Crossword Generator
« Reply #28 on: August 26, 2019, 11:48:51 pm »
I have tried both version of this program in a newly downloaded and  clean version 1.3 of QB64 and receive the following error in BOTH versions of the crossword program. I have disabled my virus checker to run the program uninterrupted (Avast).
qb64Error1.bmp
* qb64Error1.bmp (Filesize: 8.89 MB, Dimensions: 2960x1050, Views: 211)

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #29 on: August 27, 2019, 04:33:14 am »
I have tried both version of this program in a newly downloaded and  clean version 1.3 of QB64 and receive the following error in BOTH versions of the crossword program. I have disabled my virus checker to run the program uninterrupted (Avast).

Exile, I believe that your error occurs because the program cannot find the dictionary files.  Are you sure that you have the Run Option 'Output EXE to Source Folder' checked?