Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dictionary

65 views
Skip to first unread message

Bischoop

unread,
Dec 30, 2013, 6:38:20 PM12/30/13
to
I have a txt file with some words, and need simply program that will
print me words containing provided letters.

For example:
Type the letters:
(I type: g,m,o)
open the dictionary.txt
check words containing:g,m,o in dictionary.txt
if there are words containing: ["g", "m", "o" ]
print words with g,m,o

Walter Hurry

unread,
Dec 30, 2013, 6:56:34 PM12/30/13
to
Well, what have you tried so far, and what result did you get?

The incredibly helpful people here will provide advice, guidance and
pointers, but it won't help you at all if they just do your homework for
you.

Message has been deleted

Bischoop

unread,
Jan 8, 2014, 6:51:26 PM1/8/14
to
Dennis Lee Bieber wrote:

> On Mon, 30 Dec 2013 18:38:20 +0000, Bischoop <mar...@jakis.adres.em>
> declaimed the following:
> Vague requirement...
>
> Do you need:
> 1 any word containing any single letter
> 2 any word containing all supplied letters (is there a limit on how
many
> letters?)
> 3 any word containing the supplied letters in the entered order,
but not
> necessarily adjacent to each other
> 4 any word containing the supplied letters in adjacent sequence
> 5 any word that begins with the supplied sequence of letters

1.yes
2. Any combination with supplied letters. It would be great if possible that
I could set also the combination for example: show me all words with: l,x
3. the order doesn't matter
4. doesnt matter
5 doesnt matter.

Bischoop

unread,
Jan 8, 2014, 7:00:02 PM1/8/14
to
Honestly Im newbie in Python, years ago (10 already) I wrote simply program
something like a TEST: Capitals of Countries. You could learn the capitals
of some countries, and then you could try to solve a test. I know it's seems
so simply for you guys but I was quite pride of myself :-)

Now because of free time I took my book which I used years ago about python
and try to learn it again, and as motivation I try to write the program I
described above just to give me a kick :-), however got no idea how to start
it, I meand there is so many moduls (import this, import that), I know how
to open, read file etc. Just stuck with that, got no clue what and how use
this that what I need to seek the words from the files if I need a words
with letters I want.
Message has been deleted

Chris Angelico

unread,
Jan 9, 2014, 12:21:43 AM1/9/14
to pytho...@python.org
On Thu, Jan 9, 2014 at 11:13 AM, Dennis Lee Bieber
<wlf...@ix.netcom.com> wrote:
> #generate search re expression representing
> # .* any character/multiple -- leading
> # [l|e|t|t|e|r] match any of the letters supplied
> # .* any character/multiple -- trailing
> needle = ".*[" + "|".join(list(letters.lower())) + "].*"

I don't think this will do what you think it will. It'll match
anything that has any one of the supplied letters (or a pipe; it's a
character class, so the pipe has no significance and is simply part of
the class). I'm not sure a regex is the best thing here; but what you
could do is sort the letters and sort the letters in the words:

pat = ".*".join(sorted(letters.lower()))
for word in open("/usr/share/dict/words"): # Ought to use with
if re.search(pat, ''.join(sorted(word))): print(word)

ChrisA

wxjm...@gmail.com

unread,
Jan 9, 2014, 8:31:55 AM1/9/14
to
>>> # a starting point
>>> lettres = set('üœŸ')
>>> Wörter = ['abcüœŸb', 'aüꜟ', 'üœŸzzz', 'üœzz', 'Strauẞ', '', 'nul']
>>> for word in Wörter:
... tmp = set(word)
... print('{:10} : {}'.format(word, lettres.issubset(tmp)))
...
abcüœŸb : True
aüꜟ : True
üœŸzzz : True
üœzz : False
Strauẞ : False
: False
nul : False
>>>

0 new messages