Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #63543

Re: Dictionary

Path csiph.com!usenet.pasdenom.info!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'example:': 0.03; 'matches': 0.07; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'trailing': 0.09; 'jan': 0.12; 'suggest': 0.14; '"o"': 0.16; '"r")': 0.16; '>>>i': 0.16; 'adjacent': 0.16; 'doesnt': 0.16; 'expression,': 0.16; 'letters.': 0.16; 'message-id:@4ax.com': 0.16; 'need:': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'supplied': 0.16; 'true:': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'skip:f 30': 0.19; 'entered': 0.20; '>>>': 0.22; 'print': 0.22; 'url:home': 0.24; 'mon,': 0.24; "i've": 0.25; 'skip:" 30': 0.26; 'header:X-Complaints-To:1': 0.27; '----': 0.29; 'words': 0.29; "doesn't": 0.30; 'dec': 0.30; 'txt': 0.31; 'file': 0.32; 'regular': 0.32; 'could': 0.34; "can't": 0.35; 'something': 0.35; 'but': 0.35; 'there': 0.35; 'version': 0.36; 'combination': 0.36; 'doubt': 0.36; 'representing': 0.36; 'sequence': 0.36; 'words,': 0.36; 'charset:us-ascii': 0.36; 'possible': 0.36; 'skip:o 20': 0.38; 'skip:[ 10': 0.38; 'to:addr :python-list': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'expression': 0.60; 'letters': 0.60; 'break': 0.61; 'full': 0.61; 'matter': 0.61; 'simply': 0.61; 'show': 0.63; 'great': 0.65; 'containing': 0.69; 'limit': 0.70; '(is': 0.84; 'received:108': 0.93; '2013': 0.98
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Dennis Lee Bieber <wlfraed@ix.netcom.com>
Subject Re: Dictionary
Date Wed, 08 Jan 2014 19:13:27 -0500
Organization IISS Elusive Unicorn
References <x4jwu.3413$Bs5.1921@fx09.am4> <mailman.4725.1388433616.18130.python-list@python.org> <P6hzu.2028$Wn7.1602@fx20.am4>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host adsl-108-79-222-86.dsl.klmzmi.sbcglobal.net
X-Newsreader Forte Agent 6.00/32.1186
X-No-Archive YES
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.5214.1389226408.18130.python-list@python.org> (permalink)
Lines 79
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1389226408 news.xs4all.nl 2902 [2001:888:2000:d::a6]:39571
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:63543

Show key headers only | View raw


On Wed, 08 Jan 2014 18:51:26 +0000, Bischoop <martin@jakis.adres.em>
declaimed the following:

>Dennis Lee Bieber wrote:
>
>> On Mon, 30 Dec 2013 18:38:20 +0000, Bischoop <martin@jakis.adres.em>
>> declaimed the following:
>> 
>>>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
>> 
>> 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.

	No doubt someone will suggest using a regular expression, but since
I've never used the re/regex modules I can't give the full work...
PseudoCode may be something like

fwin = open("dictionary.txt", "r")
haystack = fwin.read().lower().split("\n")
fwin.close()

while True:
	letters = input("Enter letters> ")
	if not letters: break
	#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())) + "].*"
	#do a regular expression search of haystack using needle as
	#search condition
	# print matches

----

	The slower non-re version might be something like

fwin = open("dictionary.text", "r")
haystack = fwin.read().lower().split("\n")
fwin.close()

while True:
	letters = input("Enter letters> ").lower()
	if not letters: break
	for word in haystack:
		for letter in letters:
			if letter in word:
				print word
				break
-- 
	Wulfraed                 Dennis Lee Bieber         AF6VN
    wlfraed@ix.netcom.com    HTTP://wlfraed.home.netcom.com/

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Dictionary Bischoop <martin@jakis.adres.em> - 2013-12-30 18:38 +0000
  Re: Dictionary Walter Hurry <walterhurry@gmail.com> - 2013-12-30 18:56 +0000
    Re: Dictionary Bischoop <martin@jakis.adres.em> - 2014-01-08 19:00 +0000
      Re: Dictionary wxjmfauth@gmail.com - 2014-01-09 00:31 -0800
  Re: Dictionary Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2013-12-30 15:00 -0500
    Re: Dictionary Bischoop <martin@jakis.adres.em> - 2014-01-08 18:51 +0000
      Re: Dictionary Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-01-08 19:13 -0500
      Re: Dictionary Chris Angelico <rosuav@gmail.com> - 2014-01-09 11:21 +1100

csiph-web