LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   extract words frm dictionary (https://www.linuxquestions.org/questions/linux-newbie-8/extract-words-frm-dictionary-815182/)

suraj sharma 06-19-2010 04:18 PM

extract words frm dictionary
 
could u pls tell me which would be the efficient way to extract all the words(which has all the specified letters ) from a linux dictionary..

example
get all the valid words with letters with letters A,B,C,D,E,H

yooy 06-19-2010 04:40 PM

what do you mean by linux dictionary?

w1k0 06-19-2010 07:58 PM

It depends on what you mean by dictionary and valid words. For example: on my machine in /usr/share/dict/ directory there is a file named words. It starts with ``aback'', ends with ``zoos'' and contains 38619 words. To search through it the words containing a, b, c, d, e and h letters exclusively I use the command:

Code:

egrep -e "^[abcdeh]+$" words
In result it displays 47 words:

Code:

abbe
abed
accede
acceded
ace
ache
ached
ad
add
added
ah
ahead
babe
bad
bade
bah
be
beach
beached
beachhead
bead
beaded
bed
bedded
bee
beech
behead
cab
cache
cached
cede
ceded
dad
dead
decade
deed
deeded
each
ebb
ha
had
he
head
headache
headed
heed
heeded

On the other hand if you mean dictionary in any other format than plain ASCII text file extracting words from it could be tricky or simply impossible.

suraj sharma 06-20-2010 09:19 AM

i mean the words present in usr/share/dict/words in linux

suraj sharma 06-20-2010 09:28 AM

hey can u pls tell me how to do the same in a progaram written in java ?
can i use
egrep -e "^[abcdeh]+$" words

inside java program which runs on linux machine?

w1k0 06-20-2010 10:54 AM

Read that thread and don't stop on the first answer.


All times are GMT -5. The time now is 11:40 PM.