Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Program needed for change of letters within a stringHelpful Member!(5) 

german12 (Programmer) (OP)
28 Dec 04 20:31
Tonight I saw a riddle on television.

They looked for a meaningful german word, however the problem has nothing to do with the language.
They placed the following 9 letters on screen:

       B L U T M E O P F

and asked "what meaningful word is hidden here?"

I know that this has to been recognized as a string-change-problem where every letter can have the place from 1 to 9 (no doubles) to cover all possibilities and then it would be easy (for me,not easy for the program) to find out what a meaningful word is.

I thought about a loop to deliver me all possibilities but I
did not come to a solution.

How has that loop to be coded?
And - how many words (senseless or not) will that produce in total in case of this example ?

It is not necessary to compare the words found with an enzyklopedia.

I know that Foxpro can do it with just a few commands (as well as Basic or C++) but in Fox it would be most understandable for me.

Thanks folks.

By the way - they awarded 4,000 Euro for the right word, and
next time when they have a similiar riddle, I would run such
a evaluation-program to be the first who phones *ggg

Peace worldwide - it starts here...

Helpful Member!  baltman (TechnicalUser)
28 Dec 04 21:41
Helpful Member!  craigsboyd (IS/IT--Management)
28 Dec 04 21:44
You can use the Permutation code I posted in:

All Combinations
Thread184-823742

...just modify the array so that it includes an element for each of the 9 letters you've been given.


www.sweetpotatosoftware.com

german12 (Programmer) (OP)
29 Dec 04 4:01
Hi Craig,

many thanks, your prog was the easiest for me to modify and
I really came up with 362,880 records found by your program which is the solution of 9! = (1*2*3*4*5*6*7*8*9).
I changed your program a litte to write all the records directly into an opened *.dbf-file by appending each found record - which was much more faster than putting the results on screen - which I did not expect.

Now it would be easy to compare that database with a german encylopaedia (I am just looking for one) and then ask by a litte program for matching records.

A star for you!

regards
Klaus

Peace worldwide - it starts here...

craigsboyd (IS/IT--Management)
29 Dec 04 4:38
german12,

Glad it helped.  If you get time perhaps you could post the revised code here with the results going into a table instead of being printed on the screen... might help someone in the future.

baltman,

I just noticed you slipped in before me or I wouldn't have posted the link again.


www.sweetpotatosoftware.com

Helpful Member!  KoenPiller (Programmer)
29 Dec 04 5:46
Klaus,
See to it that your will get a most complete GermanDictionary and than run the code Calvin Hsia constructed for a Phonebook challange.
http://blogs.msdn.com/vsdata/archive/2004/04/05/107986.aspx
extremely fast!

Best regards,
Koen
Helpful Member!  TheRambler (Programmer)
29 Dec 04 8:53
Hi,

You can get some more ideas for your program here.
german12 (Programmer) (OP)
29 Dec 04 15:37
@Craig: I will display the modification within the next days,
because I would like to try also to create the dimension statement right away from the given word (abcd..)in order to automate that program a little bit more.
(Hope that my knowledge is good enough, as I am not a professional...)

@koen: I looked at that program and tried it, however there is reported an error when I ran it:
a class-definition missing for the command line:
ox=CREATEOBJECT('dictionary.dict')            && Instantiate the dictionary COM object.

Anyway, I would like to study the idea of that program to use
what I can understand for my purpose. Thank you so much.

@TheRambler: A great Site! It is at least that what I am trying here - and it is more due to selectable languages.
All I reget is, that I could not see, HOW that is coded.
That is a big star for you! Thanks.

Klaus


 

Peace worldwide - it starts here...

craigsboyd (IS/IT--Management)
29 Dec 04 18:06
Here's a working example that puts the permutations to a cursor and includes a progress bar class I threw together real quick.  Cut-N-Paste the code below into a prg and execute it from within VFP:

CODE

*!* Show all permutations for a given set of characters
GetCharPermutations("PERMUTE")

PROCEDURE GetCharPermutations(tcCharacters)
    LOCAL lnMembers, lnCounter, loProgress, lnTemp, lnTemp2, lnLoopCounter, lnTotalPermutations, lnPermutationsDone
    SET ESCAPE ON
    lnMembers = LEN(tcCharacters)
    lnTotalPermutations = 1
    lnPermutationsDone = 0
    DIMENSION tcSet(lnMembers)
    DIMENSION aryIndice(lnMembers)
    FOR lnLoopCounter = 1 TO lnMembers
        tcSet(lnLoopCounter) = SUBSTR(tcCharacters, lnLoopCounter, 1)
        lnTotalPermutations = lnTotalPermutations * lnLoopCounter
    ENDFOR
    aryIndice = -1
    CREATE CURSOR crsResult (permute c(lnMembers))
    loProgress = CREATEOBJECT("progress", "Processing...", 0, lnTotalPermutations, 0)
    loProgress.show()
    DO WHILE .T.
        IF(aryIndice(1) < 0)
            lnCounter = 1
            DO WHILE  lnCounter < lnMembers + 1
                aryIndice(lnCounter) = lnCounter - 1
                lnCounter = lnCounter + 1 && was above
            ENDDO
            lnBeginning = lnMembers +1
            lnEnd = lnMembers
            DO WHILE lnBeginning < lnEnd
                lnTemp2 = aryIndice(lnBeginning)
                aryIndice(lnBeginning) = aryIndice(lnEnd)
                lnBeginning = lnBeginning + 1
                aryIndice(lnEnd) = lnTemp2
                lnEnd = lnEnd - 1
            ENDDO
            lnPermutationsDone = lnPermutationsDone + 1
            loProgress.VALUE = lnPermutationsDone
            INSERT INTO crsResult (permute) VALUES (LEFT(DisplayString(lnMembers, @tcSet, @aryIndice), lnMembers))
            LOOP
        ELSE
            lnCounter = lnMembers - 1
            DO WHILE lnCounter >= 1 AND aryIndice(lnCounter) >= aryIndice(lnCounter + 1)
                lnCounter = lnCounter - 1
            ENDDO
            IF(lnCounter < 1)
                EXIT
            ELSE
                lnLeast = lnCounter + 1
                lnTemp = lnCounter + 2
                DO WHILE lnTemp < lnMembers + 1
                    IF(aryIndice(lnTemp) < aryIndice(lnLeast) AND aryIndice(lnTemp) > aryIndice(lnCounter))
                        lnLeast = lnTemp
                    ENDIF
                    lnTemp = lnTemp + 1 && was above
                ENDDO
                lnTemp2 = aryIndice(lnCounter)
                aryIndice(lnCounter) = aryIndice(lnLeast)
                aryIndice(lnLeast) = lnTemp2
                IF (lnMembers > lnCounter)
                    lnBeginning = lnCounter + 1
                    lnEnd = lnMembers
                    DO WHILE lnBeginning < lnEnd
                        lnTemp2 = aryIndice(lnBeginning)
                        aryIndice(lnBeginning) = aryIndice(lnEnd)
                        lnBeginning = lnBeginning + 1
                        aryIndice(lnEnd) = lnTemp2
                        lnEnd = lnEnd - 1
                    ENDDO
                    lnBeginning = lnMembers + 1
                    lnEnd = lnMembers
                    DO WHILE lnBeginning < lnEnd
                        lnTemp2 = aryIndice(lnBeginning)
                        aryIndice(lnBeginning) = aryIndice(lnEnd)
                        lnBeginning = lnBeginning + 1
                        aryIndice(lnEnd) = lnTemp2
                        lnEnd = lnEnd - 1
                    ENDDO
                ENDIF
                lnPermutationsDone = lnPermutationsDone + 1
                loProgress.VALUE = lnPermutationsDone
                INSERT INTO crsResult (permute) VALUES (LEFT(DisplayString(lnMembers, @tcSet, @aryIndice), lnMembers))
                LOOP
            ENDIF
        ENDIF
    ENDDO
    RELEASE loProgress
    IF MESSAGEBOX("Done processing '" + tcCharacters + "' would you like to browse the results?",36,"PROCESS FINISHED") = 6
        GO TOP IN "crsResult"
        BROWSE
    ENDIF
ENDPROC


FUNCTION DisplayString(tcMembers, tcSet, tcIndice)
    LOCAL lnCounter, lcString
    lcString = []
    FOR lnCounter = 1 TO tcMembers
        IF (tcIndice(lnCounter) + 1) != 0
            lcString = lcString + TRANSFORM(tcSet(tcIndice(lnCounter)+1))
        ENDIF
    ENDFOR
    RETURN ALLTRIM(lcString)
ENDFUNC

DEFINE CLASS progress AS FORM

    AUTOCENTER = .T.
    ALWAYSONTOP = .T.
    TOP = 0
    LEFT = 0
    HEIGHT = 74
    WIDTH = 298
    DOCREATE = .T.
    CAPTION = ""
    TITLEBAR = 0
    BORDERSTYLE = 2
    VALUE = 0
    NAME = "frmProgress"
    MIN = 0
    MAX = 100
    
    PROCEDURE INIT
        LPARAMETERS tcTitle, tnMin, tnMax, tnValue
        LOCAL lnCounter, lnLeft, lcShapeName

        THIS.ADDOBJECT("shape26", "Shape")
        WITH THIS.shape26
            .TOP = 23
            .LEFT = 12
            .HEIGHT = 25
            .WIDTH = 277
            .BACKSTYLE = 0
            .SPECIALEFFECT = 0
            .VISIBLE = .T.
        ENDWITH

        THIS.ADDOBJECT("title", "label")
        WITH THIS.TITLE
            .BACKSTYLE = 0
            .CAPTION = ""
            .HEIGHT = 18
            .LEFT = 12
            .TOP = 3
            .WIDTH = 277
            .VISIBLE = .T.
        ENDWITH

        THIS.ADDOBJECT("percentage", "label")
        WITH THIS.percentage
            .FONTBOLD = .T.
            .ALIGNMENT = 2
            .BACKSTYLE = 0
            .CAPTION = ""
            .HEIGHT = 18
            .LEFT = 12
            .TOP = 52
            .WIDTH = 277
            .FORECOLOR = RGB(0,128,192)
            .VISIBLE = .T.
        ENDWITH

        lnLeft = 13
        FOR lnCounter = 1 TO 25 && Easier than adding and removing them should progress go backwards at some point
            lcShapeName = "Shape" + TRANSFORM(lnCounter)
            THIS.ADDOBJECT(lcShapeName, "Shape")
            WITH THIS.&lcShapeName
                .TOP = 24
                .LEFT = lnLeft
                .HEIGHT = 23
                .WIDTH = 10
                .BORDERSTYLE = 0
                .SPECIALEFFECT = 1
                .VISIBLE = .F.
                .BACKCOLOR = RGB(0,128,192)
            ENDWITH
            lnLeft = lnLeft + 11
        ENDFOR

        IF TYPE("tcTitle") = "C"
            THIS.TITLE.Caption = tcTitle
        ENDIF
        IF TYPE("tnMin") = "N"
            THIS.MIN = tnMin
        ENDIF
        IF TYPE("tnMax") = "N"
            THIS.MAX = tnMax
        ENDIF
        IF TYPE("tnValue") = "N"
            THIS.VALUE = tnValue
        ENDIF
    ENDPROC

    PROCEDURE value_assign
        LPARAMETERS vNewVal
        LOCAL lnCounter, lcShapeName, lnPercentage
        THIS.LOCKSCREEN = .T.
        lnPercentage = INT(m.vNewVal/(THIS.MAX - THIS.MIN)*100)
        FOR lnCounter = 1 TO 25
            lcShapeName = "Shape" + TRANSFORM(lnCounter)
            this.&lcShapeName..VISIBLE = lnCounter <= (lnPercentage/4)
        ENDFOR
        THIS.percentage.Caption = TRANSFORM(lnPercentage) + "%"
        THIS.LOCKSCREEN = .F.
        IF lnPercentage = 100 && Show this for a .5 seconds so user can see it
            INKEY(.5,"H")
        ENDIF
        THIS.VALUE = m.vNewVal
    ENDPROC

    PROCEDURE max_assign
        LPARAMETERS vNewVal
        THISFORM.VALUE = THISFORM.VALUE && in case max is changed refresh progress bar
        THIS.MAX = m.vNewVal
    ENDPROC

    PROCEDURE min_assign
        LPARAMETERS vNewVal
        THISFORM.VALUE = THISFORM.VALUE && in case min is changed refresh progress bar
        THIS.MIN = m.vNewVal
    ENDPROC

ENDDEFINE


www.sweetpotatosoftware.com

german12 (Programmer) (OP)
29 Dec 04 18:51
Hi, Craig, here is your modified code.
Would be glad if you could test it once.

Regards
Klaus

CODE


*!*    Wordmix.prg

*!*    Authors: Craig Boyd and Klaus Briesemeister /2004

*!*    This prog changes the position of a given word for each letter (permutation)
*!*    Example: abc leads to  abc,acb, bac, bca, cab, cba (6 possibilities)
*!*    Formular for the amounts to be expected is the faculty of the amount of
*!*    letters within the word.
*!*    Example: A word which consists of 5 letters will be 5! = 1*2*3*4*5 = 120  possible words.

*!*    This permutation program is based on Craig Boyds permutation-Program shown in
*!*    http://www.tek-tips.com/viewthread.cfm?qid=82374
*!*    My program would not work without this basis-program as it contains the highly sophisticated
*!*    algorithm-loops for the permutation.

*!*    The modifications made by me are mainly as follows:
*!*    1)The hard-coded dimension is soft-coded now.
*!*    That means one can input any word and the program will automatically adjust the
*!*    DIMENSION to be used.

*!*    2)All output will directly be written into a dbf-file named wortmix.
*!*   Field name = wort, field-type = character, length = variable
*!*      The structure of this file will be automatically built by the users input.

*!*    3)The user can see in advance, how many records will be generated and can stop
*!*      the process (cancel) in advance, when the file seems to become too big.
*!*
*!*    The created file will be overwritten with every new input of the given basic word


*Code


CLEA
CLEAR WINDOW ALL
CLOSE DATABASES
SET SAFETY OFF
CLEAR

*Inputmask
searchedword =INPUTBOX("Give me a word for permutation?","Your word?","abc")
DO WHILE LEN(searchedword) = 0   && Input requested
    searchedword =INPUTBOX("Give me a word for permutation?","Your word?","abc")
ENDDO


wordlength = (LEN(searchedword)) && to define the field-width


*Show the records which will be calculated in advance
*by the faculty-formular....
RECORDS = 1
FOR i = 1 TO wordlength
    RECORDS = RECORDS * i
ENDFOR

*...to the user
cMessageTitle = 'Records to be calculated for:' + searchedword
cMessageText = "Your calculation will lead to: "+ALLTRIM(STR(RECORDS))+ " records - Continue?"
nDialogType = 4 + 32 + 256
*  4 = Yes and No buttons
*  32 = Question mark icon
*  256 = Second button is default

nAnswer = MESSAGEBOX(cMessageText, nDialogType, cMessageTitle)



*Build automatically the dimension based on the wordlenght via user-input
DIMENSION aryGroup(wordlength)

*Build automatically the array-elements based on the users input by
*a loop (each single letter is a different array-element)
*Example: Input = abc then: arygroup(1) = a, arrygroup(2) = b,arrygroup(3) = c)
firstword = ""
FOR i = 1 TO wordlength
    groupelement = SUBSTR(searchedword, i, 1)
    aryGroup(i) = [&groupelement]
    firstword = firstword+groupelement
ENDFOR

*Give the user a chance to break when result will be too high
*means: calculate the records (n! faculty)
DO CASE
CASE nAnswer = 6 && Yes
*do nothing
CASE nAnswer = 7 && No
    CLEA
    CLOSE DATA
    CANCEL
ENDCASE

*Build a table automatically
CREATE TABLE wortmix (wort C(wordlength))
APPEND BLANK
REPLACE wort WITH firstword &&given the first record.


*

GetPermutations(wordlength,@aryGroup)
GO TOP
BROWSE TITLE FULLPATH(DBF())+" "+ ALLTRIM(STR(RECCOUNT()))+ " Records ready"


*Here mainly starts craigs code:

PROCEDURE GetPermutations(tcSize, tcSet)
LOCAL lnMembers, lnCounter, lnTemp, lnTemp2
lnMembers = ALEN(tcSet)
DIMENSION aryIndice(lnMembers)
counter = 1
aryIndice = -1
DO WHILE .T.
    IF(aryIndice(1) < 0)
        lnCounter = 1
        DO WHILE  lnCounter < lnMembers + 1
            aryIndice(lnCounter) = lnCounter - 1
            lnCounter = lnCounter + 1 && was above
        ENDDO
        lnBeginning = tcSize +1
        lnEnd = lnMembers
        DO WHILE lnBeginning < lnEnd
            lnTemp2 = aryIndice(lnBeginning)
            aryIndice(lnBeginning) = aryIndice(lnEnd)
            lnBeginning = lnBeginning + 1
            aryIndice(lnEnd) = lnTemp2
            lnEnd = lnEnd - 1
        ENDDO
        ?LEFT(DisplayString(lnMembers, @tcSet, @aryIndice), tcSize)
        LOOP
    ELSE
        lnCounter = lnMembers - 1
        DO WHILE lnCounter >= 1 AND aryIndice(lnCounter) >= aryIndice(lnCounter + 1)
            lnCounter = lnCounter - 1
        ENDDO
        IF(lnCounter < 1)
            EXIT
        ELSE
            lnLeast = lnCounter + 1
            lnTemp = lnCounter + 2
            DO WHILE lnTemp < lnMembers + 1
                IF(aryIndice(lnTemp) < aryIndice(lnLeast) AND aryIndice(lnTemp) > aryIndice(lnCounter))
                    lnLeast = lnTemp
                ENDIF
                lnTemp = lnTemp + 1 && was above
            ENDDO
            lnTemp2 = aryIndice(lnCounter)
            aryIndice(lnCounter) = aryIndice(lnLeast)
            aryIndice(lnLeast) = lnTemp2
            IF (tcSize > lnCounter)
                lnBeginning = lnCounter + 1
                lnEnd = lnMembers
                DO WHILE lnBeginning < lnEnd
                    lnTemp2 = aryIndice(lnBeginning)
                    aryIndice(lnBeginning) = aryIndice(lnEnd)
                    lnBeginning = lnBeginning + 1
                    aryIndice(lnEnd) = lnTemp2
                    lnEnd = lnEnd - 1
                ENDDO
                lnBeginning = tcSize + 1
                lnEnd = lnMembers
                DO WHILE lnBeginning < lnEnd
                    lnTemp2 = aryIndice(lnBeginning)
                    aryIndice(lnBeginning) = aryIndice(lnEnd)
                    lnBeginning = lnBeginning + 1
                    aryIndice(lnEnd) = lnTemp2
                    lnEnd = lnEnd - 1
                ENDDO
            ENDIF

*Write your results into a dbf-file wortmix.dbf
            APPEND BLANK
            REPLACE wort WITH LEFT(DisplayString(lnMembers, @tcSet, @aryIndice), tcSize)
            LOOP
        ENDIF
    ENDIF
ENDDO
ENDPROC

*--------------------------------------------------------------------------------------
FUNCTION DisplayString(tcMembers, tcSet, tcIndice)
LOCAL lnCounter, lcString
lcString = []
FOR lnCounter = 1 TO tcMembers
    IF (tcIndice(lnCounter) + 1) != 0
        lcString = lcString + TRANSFORM(tcSet(tcIndice(lnCounter)+1))
    ENDIF
ENDFOR
RETURN ALLTRIM(lcString)

*end of program

Peace worldwide - it starts here...

german12 (Programmer) (OP)
29 Dec 04 19:15
@Craig: A very fine built in - progress-bar.
The user stays perhaps patient when the program runs.

Sorry that I did not see it earlier, otherwise I would have built it into my modified program as well.
Perhaps later....

The performance-gain by using an open file and just REPLACE only the within an APPEND command is great, isn't it?


At the moment I think about what has to be done when one
has made an input of let's say a word-length of 13.

That would lead to a file of 6,227,020,800 records.

Therefore I built a brake in my modifications, but it would
be nicer to have the chance while your progress-bar runs, but how, without reducing performance?

regards
Klaus
 







Peace worldwide - it starts here...

baltman (TechnicalUser)
29 Dec 04 21:25
A more efficient methodology would be to let VFP do the heavy listing if you have a word list to begin with. I'm no German expert, but I did find a small word list. It couldn't solve your particular riddle, but I made one of my own.

Brian

CODE

*download http://www.dict.cc/download/dict-wordlist-de-en.zip

CREATE TABLE GermanWL (WordData c(80))
APPEND FROM dict-wordlist-de-en.txt TYPE sdf
REPLACE ALL WordData WITH UPPER(WordData)

lcLetters=[AFLLOSTEN]

lcSearchClause=[]
lcLetters=UPPER(lcLetters)
 FOR lnLetters= 1 TO LEN(lcLetters)
  lcSearchClause = lcSearchClause + [ and ']+SUBSTR(lcLetters,lnLetters,1)+['$LEFT(WordData,ATC(CHR(32),WordData,1))]
 ENDFOR
 
 lcSearchClause = [LEN(LEFT(worddata,ATC(CHR(32),worddata,1)))-1=LEN(lcLetters)] + lcSearchClause
 
SELECT * from GermanWL WHERE &lcSearchClause nowait

BROWSE NOWAIT
german12 (Programmer) (OP)
30 Dec 04 20:01
Great Brian!
I tested your prog and it worked also with german words (of course, because the problem is not language-bounded.)
This is really a more efficient method - i still have the problem to get a german word-language book which contains more words, but for a first trial your prog is very useful und extremely short.

A big star for you!!!

Happy New Year to all of you.
I learned a lot with this question.
Thx.

Klaus






Peace worldwide - it starts here...

baltman (TechnicalUser)
30 Dec 04 20:20
After posting it occured to me that using OCCURS(EachChrInString)=OCCURS(InWord) instead of '$' would be even better... but yes, this method allows you to test really long words quickly whereas testing each possible permutation would take a really really long time.

Good luck. If you win please share some of the prize with Tek-Tips :)

Brian
Helpful Member!  OlafDoschke (Programmer)
3 Jan 05 10:34
Hi Klaus,

Well, the riddle itself isn't hard: TOPFBLUME
(Pot flower).

But as this was just an example the strategy to
create all permutations of the word is okay for
a computer, but brian's idea of searching words
with the needed letters should be much faster.

You may also start with extracting only words
with 9 characters and then search for those words
with all the letters in them.

Finding word's with identical length is easy.
Make an INDEX ON LEN(ALLTRIM(cWordfield)) TAG Len.
Then Set Order to Len, Set Key To 9 and you can
scan through such words only.

But such riddles are solved quite fast even without
a computer. The thing is, you have to get through
when calling in. You don't think the viewers take
long to solve such a puzzle, just because only
every 5 minutes or so a caller is choosen? They
have to earn the 4000 EUR (plus profit) from the
49 cents per call...

Bye, Olaf.
KoenPiller (Programmer)
3 Jan 05 13:47
Hi Klaus,

If I understand you correctly you are looking for the anagram of a given word/letters.
Brian's code works but fails on words/combinations where letters occur > 1.
I think I created a routine which will also deal with that. However I shall need a list of all German words. Can you supply?

Bye Bye,

Koen
german12 (Programmer) (OP)
3 Jan 05 19:35
@Koen - as I mentioned already above in my answers, there was an error when I tried your program for the line....
 ox=CREATEOBJECT('dictionary.dict') - vpf reports a missing class-definition for dictionary.dict -however you did not answer and therefore your program was out of my sight.

They are more real senseful words which I am looking for (may
be that they are called anagrams as a strict definition)  however the problem arose that one can have a lot of answers (e.g. if a search entry has a length of only 7 letters, you are overwhelmed with n!=7) = 5,040 results and therefore I concentrated myself on Brian's program as he had already a wordbook written in German included, because I had no electronical one.
                    -----

@Olaf - thx for the tip by indexing a field via its length
(I never did that before) and - yes - you are right, they
have to earn their money before they hand it over.
I tried it several times but always had no luck.
No one can proof what really happens in the background.
Theoretically they can tell ALL viewers that they did not come through, and in TV you will hear only wrong answers produced by people belonging to them - and the last person - who has the right answer is also belonging to them.....

Who does control them?

Regards to both of you.

Klaus

Peace worldwide - it starts here...

baltman (TechnicalUser)
3 Jan 05 21:15
Having no sense of German I could not judge, but if I modify my lcSearchClause to match a length >= the length of the string I do indeed get many 'flower pot' related results from the dictionary I posted a link to.

I actually expected that the riddle was much more difficult to solve and would not have been found in my 'freeware' German dictionary.

Brian
OlafDoschke (Programmer)
5 Jan 05 6:45
Another Idea:

create a new field in the dictionary containing the (upper case) letters of the word in alphabetical order.

Then searching for possible words would be done by sorting the letters of the puzzle and then seeking all words of the dictionary with the same letters. You only once need to sort all words of the dictionary. Combined with an index on the length this would be very fast even for longer words in a large dictionary.

To sort a word:

CODE

? sortword("Blutmeopf")
? sortword("Topfblume")
* both result in BEFLMOPTU

Function sortword()
   LParameters tcWord
   
   tcWord = IIf(Empty(tcWord),"",Upper(AllTrim(tcWord)))
   
   Local Array laLetters[Len(tcWord)]
   Local lnCnt
   For lnCnt=1 to Len(tcWord)
      laLetters[lnCnt]=Substr(tcWord,lnCnt,1)
   EndFor lnCnt
   
   ASort(laLetters)
   
   Local lcSorted
   lcSorted = ""
   For lnCnt=1 to Len(tcWord)
      lcSorted = lcSorted + laLetters[lnCnt]
   EndFor lnCnt
   
   Return lcSorted
EndFunc

Bye, Olaf.
german12 (Programmer) (OP)
5 Jan 05 15:25
Wow, Olaf! Thats an amazing idea!
I would never had come to such a solution I think.

Big star for you!

regards
Klaus

Peace worldwide - it starts here...

german12 (Programmer) (OP)
5 Jan 05 16:07
Olaf,
(For our english friends I try to translate it partly:)
Here is a source for cheap wordbooks:

      http://www.zweitausendeins.de/

(and then as a german search-word: "Wörterbuch")
will lead to:


-----------------------------------------------------------
Grimms German Wordbook on 2 CD-ROM, 49.90 EURO

Jacob und Wilhelm Grimm: Grimms Deutsches Wörterbuch. Auf 2 CD-ROMs. Das "allerwichtigste Buch in deutscher Sprache" (Marcel Reich-Ranicki) endlich in elektronischer Version - der Digitale Grimm. Nur 49,90 EURO
---------------------------------------------------------
Langenscheidt Hand-Wordbook on CD-ROM (German-English,
English/German)
220,000 Search-words and phrases.
Instead of 52 only 17.95 EURO.

Langenscheidts Handwörterbuch Englisch-Deutsch/Deutsch-Englisch. Das Profi-Wörterbuch auf CD-ROM. Arbeit mit und an Texten findet inzwischen fast nur noch am Computer statt. Da liegt es auf der Hand, die Nachschlagewerke auch im Computer zu haben, am besten verknüpft mit der Textverarbeitung. So einfach geht es auch bei Langenscheidts Handwörterbuch Englisch auf CD-ROM. Einfach das Wort in der gerade benutzten eigenen Anwendung (Outlook, Textverarbeitung, Internet-Browser oder andere) markieren, Taste drücken, und schon ist man beim entsprechenden Eintrag im Handwörterbuch gelandet. Rund 220.000 Stichwörter und Wendungen. Mehr Info (mit Treffer "wörterbuch"). Statt e.P. 52,00 EUR nur 17,95 EUR. Nr. 14739.
----------------------------------------------------------
The cheapest German wordbook is this:

Wordbook of the German colloquial Language on CD-ROM
Instead of 34.90 only 9.90 Euro.


Das Wörterbuch der deutschen Umgangssprache. Von Heinz Küpper. Auf CD-ROM statt 34,90 EUR (e.P.) nur 9,90 EUR.
--------------------------------------------------------


The only question is, whether there is access on these databases possible from within VFP.

What do you think?

Regards
Klaus

Peace worldwide - it starts here...

OlafDoschke (Programmer)
6 Jan 05 7:03
Hi Klaus,

I'd say that no procducer of such an electronic dictionary would make it easy for anybody to extract all data (and create another dictionary by that). So you may try one or some of these, but before you don't have it, it would only be guessing, if it's readable for foxpro. Most probably not easily.

If you have MS Word, this has an integrated dictionary. You may be able to read that out and store it in a foxpro table.

oWord = createobject("Word.Application")
for i = 1 to oWord.GetSpellingSuggestions("aa").count
? oWord.GetSpellingSuggestions("aa").Item(i).Name
endfor i

Gives you existing words quite similar to aa. Now you may loop from aa,ab,ac ... xz,yz,zz,aaa,... and then create the dictionary by that. Maybe there is a more native way to read that dictionaries.

Well, and thank's for the star.

Bye, Olaf.
german12 (Programmer) (OP)
6 Jan 05 12:22
Olaf, I tried your prog with Word97 however this error was reported:


"Element GetSpellingSuggestions kann nicht zu einem Objekt ausgewertet werden"

english:
element getspellingsuggestions can not be evaluated to an object.

What is the reason?

I do use VFP 7

Peace worldwide - it starts here...

OlafDoschke (Programmer)
6 Jan 05 13:44
Hi Klaus,

I don't think Office 97 has this function. I have Office 2003 installed. I also observed, that it won't work, if no document is open, so perhaps try:

CODE

oWord = createobject("Word.Application")
oWord.Documents.Add() && add an empty dummy document
for i = 1 to oWord.GetSpellingSuggestions("aa").count
   ? oWord.GetSpellingSuggestions("aa").Item(i).Name
endfor i

I played around a bit with this and it's rather slow. (If bomarbing word with guessed words it consumes 99% cpu time). And it's hard to extract words this way, as you must give a word that's written at least roughly similar to a real world. And if the Count is 0 it doesn't mean the guessed word is a correct one, MS Word also has no suggestions for a word roughly similiar to "asdjkjsdkh" eg.

There must be an easier way to get a decent list of words. Perhaps read in texts with APPEND FROM some.txt TYPE sdf
and then select distinct words from that.

If you have lots of large german word.docs perhaps save them as .txt or loop through oWord.ActiveDocument.Words(n).Text with n from 1 to oWord.ActiveDocument.Words().Count

You may write a programm that uses some decent sources for correctly spelled texts, like www.spiegel.de and their RSS (XML) Newsfeed and extract word's from there or anywhere on the internet as a background task.

Well, texts are all around you. And you just need the word's, not their syllables or their translations or their meanings or synonyms of them, right? Some false words also don't hurt.

http://www.dict.cc/download/dict-wordlist-de-en.zip also is a nice start. I extracted about 100,000 words of it (just the german words) and also removed brackets and stuff like {f} {m} {pl} : ! ? , with chrtran() and strtran().

Bye, Olaf.
german12 (Programmer) (OP)
6 Jan 05 15:29
Olaf, the good news: Also Word97 can do it, the only reason that it did not run first, was the missing empty document.

To gain a word-list by several documents is also a practical way but of course you can never be sure having collect all words, however better than nothing indeed.

Tomorrow I will ask via a german forum which is called

                    www.kurzefrage.de

There you can place all questions you never got answered - and
I had very often good luck with that - the answers are automatically e-mailed to me.
Have a look at it.

I will keep this forum informed about further experience.

How big is that cleaned word-list which you extracted?
In case it is not too big could you mail it to

           Igel2003@gmx.de

(I do use this adress very seldom and just to have one which I can public without any danger of misuse, so give me a note here when that was possible)


Thx for now.

Regards
Klaus

Peace worldwide - it starts here...

OlafDoschke (Programmer)
6 Jan 05 18:08
Hi Klaus,

how long can it be to not overload your gmx account? 1 MB?
Maybe I'll put it on our site as a download...

To be as short as possible, I'd make a TXT file of the data and zip that of course. Then finally it should be shorter than the original download, because it only contains the german words. And that was 2 MB (zipped), so it should come down to 1 MB.

I don't have copied all commands I used to tidy the word list, that would of course be much easier to send.

Well, I tried to get more words from GetSpellingSuggestions, and it seems that Word will give an Extra 10% Words, which would also include several forms of the words, eg singular and plural of the same word.

Until tomorrow.
Bye, Olaf.

OlafDoschke (Programmer)
7 Jan 05 9:32
Hi Klaus,

I've sent you a link to a download (<500 KB) to your GMX account. And some nice or funny anagrams I found through that word base.

Bye, Olaf.
german12 (Programmer) (OP)
7 Jan 05 19:46
Hi Olaf,

many thx for the txt-files which I downloaded.
Very funny anagrams where filtered there by you.

Even triple-anagrams, I was deeply impressed.

Here are the capacities of german Mailboxes (source:
Computerbild 26/2004 dated Dec,13.) they compared 10 mailboxes with all their technical details there:

My mailbox has a max. receiving capacity for one mail of 20 MB. (sending capacity is also 20 MB).
If you are interested in what all the other Mailboxes are
capable I could send you a screenshot.

They compared different versions of Freemail, GMX,Freenet, Lycos and Yahoo!.
         
My mailbox is free of charge.

I will mail you later on.

Bye
Klaus

Peace worldwide - it starts here...

OlafDoschke (Programmer)
9 Jan 05 12:48
The last time I used such a mailbox the limits where about 1 MB or less.

Well, now I work on an algorithm to find anagram sentences. I'll limit that to finding a word list that fits to a given sentence and leave it to the user to build sentences of them. The problem is, that the comparison of the sorted letters as footprints of the words and the sentence is of course insufficient.

The general algorithm is a recursive one, where you search a word that can be built from some or all of the letters of the sentence and if you found such a word repeat with the rest of the letters until there are no more left.

To make this search for appropriate words faster and to limit testing to words likely to be possible, I'd index words on included letters and length and would begin with searching words, that have the most seldom used letter of the sentence included in them and are short enough to be built by the letters of the sentence (or the rest of it in deeper levels of the recursive search) and begin with the longest of those words to reduce the letters of the sentence fastest.

It's a nice computational problem...

Bye, Olaf.
german12 (Programmer) (OP)
9 Jan 05 13:12
Olaf, I am glad having caused so much fun with my question  to
you.
If it is not enough word-playing pls also have a look at

http://www.tek-tips.com/viewthread.cfm?qid=980482

so that your evenings will not become boring. *ggg

I look forward to your success.

Regards
Klaus

Peace worldwide - it starts here...

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close