Skip to content

Instantly share code, notes, and snippets.

@imrehg
Created December 1, 2011 01:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save imrehg/1412505 to your computer and use it in GitHub Desktop.
Save imrehg/1412505 to your computer and use it in GitHub Desktop.
Find words that match a pattern I was looking for
"""
Match a pattern, to find what can "s____e cake" be.
This is the hard way, and matching expressions rather than words
would be better, but brute force is brute.
"""
import re
# The English Open Word List file we need to consider
# http://dreamsteep.com/projects/the-english-open-word-list.html
fname = "S Words.csv"
# Input data into an list
f = open(fname, 'r')
data = f.readline()
f.close()
datalist = data.strip().split('\r') # to handle Mac style file ending
# Select matching words
word = re.compile("^s.{4}e$")
out = [line for line in datalist if word.match(line) is not None]
# Results output
print "matching words found (%d):" %(len(out))
print "=" * 20
nstep = 8 # number of words per line
printed = ""
for i in range(0, len(out)):
printed += out[i]+"\t"
if (i+1) % nstep == 0:
printed += '\n'
print printed
matching words found (209):
====================
sacque saddle sagene saique saithe salade salame saline
sallee salpae salute samite sample sapele sapple sarape
sarnie sasine satire sative saulie savage savate savine
scalae scarce scathe scerne scheme schmoe sclate sclave
sclere sconce scopae scorse scouse scrape scribe scrike
scrine scrive scrobe scruze sculle scunge scythe searce
sebate secede secure sedate sedile seduce seethe seiche
selkie semble sememe semple sempre senate senile serape
serene serine serrae sesame setose settee settle setule
severe sewage shavie sheave shelve shikse shrike shrine
shrive shrove sickie sickle siffle silage silane silene
silkie silvae simile simple single sipple sirene sirree
sizzle sklate sleave sleaze sledge sleeve sludge sluice
smeuse smooge smouse smudge snaste snathe sneeze snooze
snudge sobole socage softie solace solute sombre somite
sonsie soogee soogie soothe sopite sorage sortie souple
source sozzle spahee sparge sparse spathe spavie specie
spence sperse sphene sphere spicae splice spline splore
sponge spouse sprite spruce spunge spurge squame square
squire stable stacte stance stanze staple starve statue
steale steane stedde steeve stelae steppe sterve stifle
stigme stimie stodge stogie stooge stoope storge strafe
strake strene striae stride strife strike stripe strive
strobe strode stroke strove stymie suable subdue subtle
suckle sudate summae sundae supine supple surfie sutile
suttee suttle suture svelte swarve swathe swerve swinge
sylvae
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment