1. Fastest Way to Check Word in Dictionary

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

Thanks! grin

new topic     » topic index » view message » categorize

2. Re: Fastest Way to Check Word in Dictionary

euphoric said...

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

I just use an empty dictionary, so I always know the answer is no. :P

Seriously, though, what does your dictionary look like? Or what are your specs for a hypothetical dictionary, if that's what you're thinking about?

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: Fastest Way to Check Word in Dictionary

euphoric said...

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

Thanks! grin

It would probably depend on the size of dictionary.

  • small: then use binary search.
  • medium: use maps or database.e
  • large: use odbc to large database.
new topic     » goto parent     » topic index » view message » categorize

4. Re: Fastest Way to Check Word in Dictionary

mattlewis said...
euphoric said...

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

Seriously, though, what does your dictionary look like? Or what are your specs for a hypothetical dictionary, if that's what you're thinking about?

I'm just using WORDS.TXT. It's got 51796 words in it. I just want to check some words against that dictionary.

new topic     » goto parent     » topic index » view message » categorize

5. Re: Fastest Way to Check Word in Dictionary

euphoric said...
mattlewis said...
euphoric said...

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

Seriously, though, what does your dictionary look like? Or what are your specs for a hypothetical dictionary, if that's what you're thinking about?

I'm just using WORDS.TXT. It's got 51796 words in it. I just want to check some words against that dictionary.

Junko solved that problem years ago, at least in the case where the words are all in memory...

http://www.rapideuphoria.com/spellchk.zip

If the words are stored as records in a Euphoria database, the EDS binary search algorithm would find a word pretty fast.

Rob

new topic     » goto parent     » topic index » view message » categorize

6. Re: Fastest Way to Check Word in Dictionary

robcraig said...
euphoric said...
mattlewis said...
euphoric said...

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

Seriously, though, what does your dictionary look like? Or what are your specs for a hypothetical dictionary, if that's what you're thinking about?

I'm just using WORDS.TXT. It's got 51796 words in it. I just want to check some words against that dictionary.

Junko solved that problem years ago, at least in the case where the words are all in memory...

http://www.rapideuphoria.com/spellchk.zip

If the words are stored as records in a Euphoria database, the EDS binary search algorithm would find a word pretty fast.

Rob

Rob, I saw that but I need a function I can call, not a command line interface. Maybe you guys can convert that and give it an API. smile

new topic     » goto parent     » topic index » view message » categorize

7. Re: Fastest Way to Check Word in Dictionary

euphoric said...
robcraig said...
euphoric said...
mattlewis said...
euphoric said...

What's the fastest way to check if a word is in a dictionary? (I need a function for this, if anybody's got one.)

Seriously, though, what does your dictionary look like? Or what are your specs for a hypothetical dictionary, if that's what you're thinking about?

I'm just using WORDS.TXT. It's got 51796 words in it. I just want to check some words against that dictionary.

Junko solved that problem years ago, at least in the case where the words are all in memory...

http://www.rapideuphoria.com/spellchk.zip

If the words are stored as records in a Euphoria database, the EDS binary search algorithm would find a word pretty fast.

Rob

Rob, I saw that but I need a function I can call, not a command line interface. Maybe you guys can convert that and give it an API. smile

OK, you knew I couldn't resist... smile

I've posted a new Recent User Contribution that should help.

It creates a Euphoria database with over 50,000 English words as records in the database. (The data portion of each record is set to 0. The word is the key portion.)

You can call a library routine, passing a word. You'll get back a simple TRUE or FALSE, depending on whether the word is in the database (English dictionary) or not.

Rob

new topic     » goto parent     » topic index » view message » categorize

8. Re: Fastest Way to Check Word in Dictionary

robcraig said...

OK, you knew I couldn't resist... smile

I also need a program that will deposit one million dollars into my checking account... grin

new topic     » goto parent     » topic index » view message » categorize

9. Re: Fastest Way to Check Word in Dictionary

robcraig said...

I've posted a new Recent User Contribution that should help.

It creates a Euphoria database with over 50,000 English words as records in the database. (The data portion of each record is set to 0. The word is the key portion.)

You can call a library routine, passing a word. You'll get back a simple TRUE or FALSE, depending on whether the word is in the database (English dictionary) or not.

That's great Rob. Thanks! smile

new topic     » goto parent     » topic index » view message » categorize

10. Re: Fastest Way to Check Word in Dictionary

integer flag one can use sign of the returned value instead of flag

function findPos(sequence s,sequence ss) searching string ss in sorted list s

it returns index of found string or insertion position if flag=1 then string was found

if flag=0 then string was not found

integer lo,hi,mid,c lo = 1 hi = length(ss)

c = compare(s,ss[1]) if c<0 then found = 0 return 1 elsif not c then found = 1 return 1 end if

c = compare(s,ss[hi]) if c>0 then found = 0 return hi+1 elsif not c then found = 1 return hi end if

while 1 do w = hi - lo if not w then found = 0 return hi elsif w<10 then lo += 1 while 1 do c = compare(s,ss[lo]) if not c then found = 1 return lo elsif c<0 then found = 0 return lo else lo += 1 end if end while else (hi-lo)>=10 mid = floor((lo + hi) / 2) c = compare(s,ss[mid]) if c<0 then x < ss[mid] hi = mid elsif c>0 then x > ss[mid] lo = mid else x = ss[mid] found = 1 return mid end if end if end while end function findPos

new topic     » goto parent     » topic index » view message » categorize

11. Re: Fastest Way to Check Word in Dictionary

The dictionary as database is great. I found in the net a list of 80.000+ words on spanish. The list replaces the accented characters separating the accent and the vowel, á is replaced by `a and ñ by ~n. This way you avoid problem with codepages, but is needed a lot some aditional code in order to make the word check.

For the interested people: A page listing where to find word lists on spanish: http://olea.org/proyectos/lemarios/

I had the same idea as Jacques. Is a waste to have a database only with key, you can make a lot of interesting thing with the definition.

By sure wiktionary.org have not legal problems to download.

You can search definition of spanish words from: http://www.rae.es/rae.html

The contents side on dictionary may include also a field for translation to another language.

Marco Achury

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu