How to get and use a dictionary

New to FreeBASIC? Post your questions here.
paul22
Posts: 24
Joined: Feb 10, 2007 19:59
Location: Montreal

How to get and use a dictionary

Postby paul22 » Jun 01, 2019 18:27

I am writing a Wordament Clone ,just for the hell of it. So far so good. My operating system is Windows 10.
So far, all my code is in freebasic - (no libraries)
I would like to know how to access a dictionary in order to check if a word exists, as in scrabble.
Any help would be greatly appreciated.
Thanks
MrSwiss
Posts: 3190
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: How to get and use a dictionary

Postby MrSwiss » Jun 01, 2019 18:32

Well, it depends lagely on what you understand, when stating 'dictionary'.
Can you give something closer to a Data-Structure, which defines it better?
E.g. Array of String, or similar ...
Alternative: post your code (what you have, so far) here, to give us some
ideas, of what you are attempting.

Btw. I'm not familiar, with what you are referring to: 'Wordament'.
Last edited by MrSwiss on Jun 01, 2019 18:49, edited 1 time in total.
paul22
Posts: 24
Joined: Feb 10, 2007 19:59
Location: Montreal

Re: How to get and use a dictionary

Postby paul22 » Jun 01, 2019 18:46

Thanks for your quick response Mr. Swiss.
Wordament is a Microsoft game in which you make words from the letters you have.
The word is a string of variable length made up from the 26 uppercase letters.
Once the word is made I would like to check to see if it is a legitimate English word.
I thought the best way of checking this is through some dictionary. I have no idea where in windows I can access a dictionary and use it to check if the word exists.
Paul22
UEZ
Posts: 335
Joined: May 05, 2017 19:59
Location: Germany

Re: How to get and use a dictionary

Postby UEZ » Jun 01, 2019 18:58

Maybe this will help you: viewtopic.php?f=7&t=26646
MrSwiss
Posts: 3190
Joined: Jun 02, 2013 9:27
Location: Switzerland

Re: How to get and use a dictionary

Postby MrSwiss » Jun 01, 2019 19:07

OK, first things, first "currently no dictionary", which sort of means, it's up
for debate "how to implement" it.
Second "where to get one"? I think the best chances are from a Word-
Processing-Application but again "is there one, on the system installed?".
(beware of copyright infringement, on this score!)

Alternative:
1) create one yourself (you're in, for a lot of work!)
2) maybe one or more can be found, on the internet?

just some ideas, so far ...

UEZ wrote:Maybe this will help you: viewtopic.php?f=7&t=26646

Not helpful at all (it's about something different).
dodicat
Posts: 5890
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: How to get and use a dictionary

Postby dodicat » Jun 01, 2019 19:23

badidea
Posts: 1417
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: How to get and use a dictionary

Postby badidea » Jun 01, 2019 21:00

For my tetris game (viewtopic.php?f=17&t=27438&start=75#p260233) I made something similar. Find (nearly) all freebasic keywords within the tetris grid (up/down, left/right) using "instr". Code without the game: Find all keywords within a string. I your case the dictionary will be a bit larger, but I don't expect a problem with that. The grid seems smaller in your case.
paul22
Posts: 24
Joined: Feb 10, 2007 19:59
Location: Montreal

Re: How to get and use a dictionary

Postby paul22 » Jun 02, 2019 19:15

Thank you all for your help.

I used dodicat's database of words but instead of using the instr method (does not work for my purpose), I indexed each of the words . I am now able to compare if a word is actually a word in the database.
Dodicat's database is OK, but it contains many abbreviations and acronyms which have to be edited out,. Example NBC or NFL are not a real words. I am working on it.
If anyone knows how to access the database (dictionary) used by Windows or the one in this editor used to create the forums posts please help.

Thank you
Paul22
badidea
Posts: 1417
Joined: May 24, 2007 22:10
Location: The Netherlands

Re: How to get and use a dictionary

Postby badidea » Jun 02, 2019 20:15

There are open source dictionaries which are used by e.g. Firefox.
E.g. this one: https://sourceforge.net/projects/wordli ... Dicts/6.0/
dodicat
Posts: 5890
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: How to get and use a dictionary

Postby dodicat » Jun 02, 2019 20:31

In the meantime here is Collin's scrabble dictionary.
There are weird but OK words in there also.
I have included a viewer to see the first and last few entries.
My favourite is number 276643.
Number 15 might be your comment.

https://www.mediafire.com/file/46ng481x1aggmsq/scrabbledictionary.zip/file
jevans4949
Posts: 1148
Joined: May 08, 2006 21:58
Location: Crewe, England

Re: How to get and use a dictionary

Postby jevans4949 » Jun 03, 2019 8:15

Probably what you need is not a "dictionary" but a "word list"; try searching for that. There appears to be one on Github in text format. I got one for a Boggle-type game I developed in Freebasic years ago, building on somebody else's idea.

Such lists may contain non-English words picked up by some web-crawler, e.g. obscure foreign currency names.
dodicat
Posts: 5890
Joined: Jan 10, 2006 20:30
Location: Scotland

Re: How to get and use a dictionary

Postby dodicat » Jun 03, 2019 8:56

In my mediafire link, splitter.txt should have been splitter.bas.
paul22
Posts: 24
Joined: Feb 10, 2007 19:59
Location: Montreal

Re: How to get and use a dictionary

Postby paul22 » Jun 03, 2019 16:07

Again, thank you all for your suggestions.
I downloaded Badidea's database of words. It works great. No modifications needed.

Long live FREEBASIC
Paul22
RockTheSchock
Posts: 220
Joined: Mar 12, 2006 16:25

Re: How to get and use a dictionary

Postby RockTheSchock » Jun 03, 2019 16:17

https://github.com/first20hours/google- ... swears.txt

Here is another word list. Just remove all 1-2 char words with regexp and then you could manually modify the file further.

regexp search and replace with editor:
^([a-z]{1,2})\r\n
Last edited by RockTheSchock on Jun 03, 2019 16:22, edited 1 time in total.
Lost Zergling
Posts: 238
Joined: Dec 02, 2011 22:51
Location: France

Re: How to get and use a dictionary

Postby Lost Zergling » Jun 03, 2019 16:18

I indexed each of the words
You're welcome have a look to LZLE (if you didn't yet). Perhaps you will like it, perhaps not.

Return to “Beginners”

Who is online

Users browsing this forum: No registered users and 17 guests