Author Topic: Crossword Generator  (Read 11456 times)

0 Members and 1 Guest are viewing this topic.

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Crossword Generator
« Reply #30 on: August 29, 2019, 06:04:18 am »
Very, very nice program !

- here I join for you the #word.rnd files in french language (with 193445 words) in uppercase letters without accent... (if somebody interested)

- Question: how export then finished grid (for instance in a text file ?)
* CROSSWORD_GEN_193445_WORDS_IN_FRENCH.zip (Filesize: 399.37 KB, Downloads: 214)
Why not yes ?

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #31 on: August 29, 2019, 07:21:38 am »
Very, very nice program !

- Question: how export then finished grid (for instance in a text file ?)

Euklides, thank you.  I attach a French version of the program, with your .rnd file renamed.  The program version is optimised for speed using the position statistics from these dictionary files.  Again, the files need to go in the original folder.

So, now we have English, Spanish and French versions.

In the French version, if you press "w" when a completed grid is dispayed, the grid will be output to a text file ("xword.txt").
* CreateurDeMotsCroises.zip (Filesize: 484.43 KB, Downloads: 209)
« Last Edit: August 30, 2019, 04:07:26 am by Qwerkey »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #32 on: September 01, 2019, 04:53:42 am »
Call for other language dictionaries


Just to finish off this topic, I thought that I'd make a multilingual version by selecting the language from a list.  So, we've already got English (which I'll change into and British English and US English), French and Spanish.

If you could provide a dictionary and rules for substituting any accented letters (or others) into a-z, I'll add them.  Italian?  Portuguese?  Dutch? German?  Any others?
« Last Edit: September 01, 2019, 12:41:09 pm by Qwerkey »

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Crossword Generator
« Reply #33 on: September 02, 2019, 01:09:28 pm »
I have a german dic, and could generate the german files.
Currently I have no time, because I go on vacation on the Mediterranean Sea.
We'll see later.

In german, you must change this (according to the rules of the crossword in Germany) :

ä -> ae
ö -> oe
ü -> ue
ß -> ss


Why not yes ?

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #34 on: September 03, 2019, 09:08:40 am »
I have now created a multilingual version of the program, which can be found in the first part of this thread - it replaces the original version.

The languages available are:

British English and US English.  I used dictionaries (found by Petoro) in Reply #18.  The separate dictionaries have fewer words than in the original version.  This has two effects: far less strange words are used; it takes somewhat longer to complete a grid.

German.  I used a dictionary in Reply #18.  Fortunately I used the conversion of letters with diacritical marks and the ß as given by euklides.

Spanish.  This is the dictionary from Reply #18, used in the Spanish version.

French.  This is a diction supplied by euklides as used in the French version.

Italian.  This is a dictionary from Reply #18, with all words containing letters outside a-z removed.

Dutch.  This is a dictionary from Reply #18, with all words containing letters outside a-z removed.

The time taken to complete a grid depends upon which language is used.  The average time taken (on my computer) is:

British English   5s (approx 50 attempts)
US English        5s (approx 50 attempts)
German          12s (approx 135 attempts)
Spanish            4s (approx 47 attempts)
French              2s (approx 37 attempts)
Italian             11s (approx 100 attempts)
Dutch               3s (approx 27 attempts)

The variations occur because of the different number of words in the various dictionaries and also because some languages have fewer letters which are common in word endings (and also to some extent in the word middle).

The searching activity is very intensive: over 200000 dictionary searches per second are made when the program is running.
« Last Edit: September 05, 2019, 09:52:21 am by Qwerkey »

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Crossword Generator
« Reply #35 on: September 03, 2019, 09:29:44 am »
Question:  Have you considered using this for numbers as well? 

Kakuro has a very crossword like feel to it, and is a very popular math puzzler which many folks enjoy.   It also might plug nicely into your crossword generator.  ;)

 https://en.m.wikipedia.org/wiki/Kakuro
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #36 on: September 05, 2019, 05:27:29 am »
Steve, I haven't (yet) sought to apply the methods to a numbers situation.  As you say, Kakuro has some analogous features.  As yet, the crossword generator is only for amusement - demonstrating how a computer finds words which can successfully cross á la crossword* - there is no actual output for the user to use.  I may come back to Kakuro in the future.  But bplus has been working on a Sudoku generator: his methods may be more pertinent.

* Wordsmiths (we know Steve to be our best) probably find the "franglais" term "á la" very incorrect.  Google implies that "crossword" in French is always in the plural, so I suppose the term should actually be "aux".  Aux, dear!

Offline SMcNeill

  • QB64 Developer
  • Forum Resident
  • Posts: 3972
    • View Profile
    • Steve’s QB64 Archive Forum
Re: Crossword Generator
« Reply #37 on: September 05, 2019, 11:05:56 am »
Steve, I haven't (yet) sought to apply the methods to a numbers situation.  As you say, Kakuro has some analogous features.  As yet, the crossword generator is only for amusement - demonstrating how a computer finds words which can successfully cross á la crossword* - there is no actual output for the user to use.  I may come back to Kakuro in the future.  But bplus has been working on a Sudoku generator: his methods may be more pertinent.

* Wordsmiths (we know Steve to be our best) probably find the "franglais" term "á la" very incorrect.  Google implies that "crossword" in French is always in the plural, so I suppose the term should actually be "aux".  Aux, dear!

If you ever want to give it a try, I assembled you a "number dictionary", which you can use to plug into the program and use to get the unique Kakuro values.  I've zipped it up for you, but I warn you -- it's quite a bit larger than most language lists.  (In fact, I was rather surprised at how many possible numbers are valid without duplicate values appearing -- 5,611,761 value number combinations!) 

Of course, feel free to ignore this as well; I was just mainly curious for myself at how large a "dictionary" would be required to adhere to the Kahuro ruleset, so I sat down and tossed together a quick little program to generate, test, and print values to a file for me.  Since I already had the file, I thought I'd share it, just in case you (or somebody else) might be interested in seeing it, so here it is.  ;)
* numbers.7z (Filesize: 3.29 MB, Downloads: 220)
https://github.com/SteveMcNeill/Steve64 — A github collection of all things Steve!

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #38 on: September 11, 2019, 12:24:44 pm »
Euklides, I was checking the .rnd files for the Multi-language version, and I discovered that the French files which you supplied have a number of duplicates.  This hasn't caused a problem, but I've rewritten the French .rnd files which are now 87% - 97% of the original size.  The new files are in the .zip file in the first part of this post.
« Last Edit: September 12, 2019, 01:00:09 am by Qwerkey »

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #39 on: September 14, 2019, 03:44:54 am »
When creating a crossword puzzle, a compiler will ensure that no word is ever used twice.  However, the idiot coder here forgot to include such a check for this in the original version.  I have now updated the program in the first part of this post.  There is also now a 100% check for contiguousness.

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Crossword Generator
« Reply #40 on: September 23, 2019, 10:55:27 am »
Euklides, I was checking the .rnd files for the Multi-language version, and I discovered that the French files which you supplied have a number of duplicates.  This hasn't caused a problem, but I've rewritten the French .rnd files which are now 87% - 97% of the original size.  The new files are in the .zip file in the first part of this post.

Yes, it is true.
In French for instance the words "livre" (book) and  "livré" (delivered) have not the same signification.
And if you transform "é" to "e", you have 2 same words.
I did not think about this when I created the files. This is the explanation.
Sorry ...
Why not yes ?

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #41 on: October 08, 2019, 05:50:28 am »
_MEM (partial) version

In order for the program to successfully create a completed grid, the processor is working flat-out doing comparisons of words (fitting tried words to existing ones and other string techniques).  Whilst the grid in the program is an array of integers (as opposed to string characters), the previous versions did not avoid some string processing.  Significant times are required to find a completed grid - see Reply #34.

_MEM processing is significantly faster than that of standard variable processing (and numeric processing is faster than that of string processing).  So I have created a version which has replaced string processing wherever possible and used _MEM object processing in places.  The program version here has reduced the times required, but not by a large factor.  The average times required to complete a grid are:

British English   4s
US English        4s
German            8s
Spanish            3s
French              1s
Italian              8s
Dutch               2s

The program is given here for completion, and you would not find a significant difference if you have already used that given in the start of this thread.  You would need to copy this .bas file into the existing folder created from the first part of this thread.  This program uses $CHECKING:OFF, and whilst it has been fully evaluated without fail, the use of this condition comes with some caution.  This version does not display the program trying to fill the created grids, and as such is rather less interesting because of that.

The desire would be to have a program which takes virtually zero time to create each completed grid, and perhaps one which works with entirely _MEM objects would do this.  This may be a future project.
* Multilingual Crossword Generator MEM.bas (Filesize: 19.52 KB, Downloads: 179)
« Last Edit: October 09, 2019, 05:04:20 am by Qwerkey »

Offline euklides

  • Forum Regular
  • Posts: 128
    • View Profile
Re: Crossword Generator
« Reply #42 on: October 09, 2019, 04:07:03 am »
Well.
Is it now possible to get the full program and the dictionnaries and the necessary files to use it ???

The version "Multilingual Crossword Generator MEM.bas" dont work because "xword.cfg" is missing. And the dictionnaries too...
Why not yes ?

Offline Qwerkey

  • Forum Resident
  • Posts: 755
    • View Profile
Re: Crossword Generator
« Reply #43 on: October 09, 2019, 04:54:54 am »
Euklides, to save duplication I referred to all the existing files which can be obtained from the very first part of this thread.  I have assumed that anybody interested enough to be reading this far down would already have downloaded the folder and files from there.  Just go to the very top of this thread.  Fortunately the $CHECKING:OFF statement comes after the OPEN "xword.cfg" statement, so no harm will come from trying to run this latest program without its associated files.