Removing some more rude words and automation of examples

This commit is contained in:
Tim Head 2014-11-21 22:52:17 +01:00
parent f47ea87475
commit 9cdd13343a
5 changed files with 54 additions and 42 deletions

View File

@ -7,9 +7,9 @@ Try it: http://these3words.herokuapp.com/
Some interesting locations:
* [Battery Park, NYC](http://these3words.herokuapp.com/nikaya-caput-mahon)
* [Downtown San Francisco](http://these3words.herokuapp.com/stitt-budged-tower)
* [Sydney, Australia](http://these3words.herokuapp.com/scone-scud-inbox)
* [Battery Park, NYC](http://these3words.herokuapp.com/huai-sora-pelayo)
* [Downtown San Francisco](http://these3words.herokuapp.com/smite-arends-nagler)
* [Sydney, Australia](http://these3words.herokuapp.com/cuyler-propor-marias)
This app was inspired by http://what3words.com/
@ -24,7 +24,7 @@ example
>>> three = these.three_words(CERN)
>>> print three
'closet-chou-maurel'
'turks-yunnan-salant'
>>> these.decode(three)
(46.232335567474365, 6.055419445037842)
@ -103,7 +103,7 @@ brought to you by [@betatim][betatim] and [@kdungs][kdungs] productions
[humanhash]: https://github.com/zacharyvoase/humanhash
[geohash]: https://code.google.com/p/python-geohash/
[cernmap]: http://these3words.herokuapp.com/closet-chou-maurel
[cernmap]: http://these3words.herokuapp.com/turks-yunnan-salant
[othercernmap]: http://these3words.herokuapp.com/spaghetti-carolina-kentucky-utah-seventeen-neptune
[bottlepy]: http://bottlepy.org/
[betatim]: https://twitter.com/betatim

13
app.py
View File

@ -11,6 +11,11 @@ from bottle import (
import thesethreewords as these
example_locs = [("sydney", (-33.867480754852295, 151.20700120925903)),
("battery", (40.70329427719116, -74.0170168876648)),
("san_fran", (37.790114879608154, -122.4202036857605))]
example_locs = dict((name,these.three_words(pos)) for name,pos in example_locs)
@get('/static/<filename:path>')
def serve_static(filename):
return static_file(filename, root='static')
@ -18,7 +23,7 @@ def serve_static(filename):
@get('/')
def index():
return template('index', err=None)
return template('index', err=None, **example_locs)
@get('/<threewords>')
@ -28,7 +33,8 @@ def showMap(threewords):
return template('map', lat=lat, lng=lng, threewords=threewords)
except:
return template('index',
err="Could not find location {}".format(threewords))
err="Could not find location {}".format(threewords),
**example_locs)
@get('/latlng/<lat:float>,<lng:float>')
@ -38,7 +44,8 @@ def showMapFromLatLng(lat, lng):
return template('map', lat=lat, lng=lng, threewords=threewords)
except:
return template('index',
err="Could not find location {}".format(threewords))
err="Could not find location {}".format(threewords),
**example_locs)
# API

View File

@ -28,12 +28,12 @@
<p>
<ul class="lead">
<li>Type in a location to find out the three words by which to remember it (try <i>1600 Pennsylvania avenue ...</i>)</li>
<li>To find the location referenced by a set of three words given to you, type them in separated by a dash (try <i>scone-scud-inbox</i>)</li>
<li>To find the location referenced by a set of three words given to you, type them in separated by a dash (try <i>{{ sydney }}</i>)</li>
<li>Go straight to exploring the map by clicking the <i>Find on Map</i> button, it will take you to Sydney</li>
</ul>
</p>
<p id="input3wordsContainer">
<input type="text" class="form-control" id="input3words" placeholder="1600 Pennsylvania .. OR scone-scud-inbox">
<input type="text" class="form-control" id="input3words" placeholder="1600 Pennsylvania .. OR {{ sydney }}">
</p>
<p>
<button id="button3words" class="btn btn-lg btn-primary">Find on Map</button>
@ -41,9 +41,9 @@
<p class="lead">
Some interesting locations to try out:
<ul class="lead">
<li><a href="nikaya-caput-mahon">Battery Park, NYC</a></li>
<li><a href="stitt-budged-tower">Downtown San Francisco</a></li>
<li><a href="scone-scud-inbox">Sydney, Australia</a></li>
<li><a href="{{ battery }}">Battery Park, NYC</a></li>
<li><a href="{{ san_fran }}">Downtown San Francisco</a></li>
<li><a href="{{ sydney }}">Sydney, Australia</a></li>
</ul>
</p>
</main>
@ -54,7 +54,7 @@
<script>
(function () {
var initialise = function () {
var default3words = 'scone-scud-inbox';
var default3words = '{{ sydney }}';
var searchbox = new google.maps.places.SearchBox(
(document.getElementById('input3words')));

View File

@ -1,3 +1,27 @@
refus
sowler
steyr
tamari
tawil
zapf
zelaya
baska
batey
besar
bolten
cusses
dtsch
elac
iesop
immo
isonzo
jehuda
kabaka
kokko
kuch
larsan
limbu
naiads
ombre
penta
planks
@ -188,7 +212,6 @@ unrwa
wender
aisled
bordes
buttle
crave
craw
dantas
@ -452,7 +475,6 @@ sidley
solidi
tiptop
wint
xxxxxx
alloa
andj
bribe
@ -1011,7 +1033,6 @@ jiaoyu
khare
newdow
notman
nudity
piazzi
raheem
rukh
@ -2524,7 +2545,6 @@ vilar
wigged
zdenek
adopts
barf
bassin
carpe
chefoo
@ -3128,7 +3148,6 @@ kimchi
kobal
marke
neils
rapee
remade
seow
sombre
@ -3655,7 +3674,6 @@ liia
maciej
ninths
pernod
pron
strato
tacos
tarter
@ -10994,7 +11012,6 @@ bere
byram
caryn
flier
nudist
resi
shai
tura
@ -11587,7 +11604,6 @@ coos
crated
fortes
loisy
nipple
pontic
renie
ativan
@ -14679,7 +14695,6 @@ lukan
nder
okun
omri
xxxxx
yuppie
jemez
severo
@ -15672,7 +15687,6 @@ cocker
gleich
glueck
maumee
xxxx
dunked
ilona
mino
@ -22819,7 +22833,6 @@ otro
reboot
shrew
mesmer
xxxix
mezzo
vanya
rizzo
@ -23424,7 +23437,6 @@ ostrom
negev
sahel
cued
xxxvii
quale
mohun
cowles
@ -23440,7 +23452,6 @@ mersey
hecate
drusus
narnia
xxxvi
flavia
mercia
maitre
@ -23512,7 +23523,6 @@ sonja
prynne
gilson
oudh
xxxv
uzbek
qaida
smit
@ -23818,7 +23828,6 @@ cavour
hellas
samoan
dhabi
xxxiv
rahner
dabbed
pawns
@ -24722,10 +24731,8 @@ amen
chats
felons
heroic
xxxiii
dickey
madmen
rapist
alger
sinha
kama
@ -24797,7 +24804,6 @@ jaunty
kemal
dykes
willi
xxxii
bree
bering
fates
@ -25595,7 +25601,6 @@ spiced
orphan
wholes
tinker
xxxi
alarm
croats
lili
@ -29919,7 +29924,6 @@ cette
benton
flat
writer
nude
brenda
stew
connor
@ -29971,7 +29975,6 @@ canaan
pius
docks
severe
raped
pang
ruskin
guess
@ -31273,7 +31276,6 @@ justly
junior
flock
norm
negro
tanks
waving
wiped
@ -31423,7 +31425,6 @@ keith
purse
cope
beans
rape
calmly
admire
linda
@ -31432,7 +31433,6 @@ sally
along
watson
jason
nazi
holmes
dashed
gown

View File

@ -13,7 +13,9 @@ damn hell homo jerk jizz knobend knob end labia lmao lmfao muff nigger
nigga omg penis piss poop prick pube pussy queer scrotum sex shit sh1t
slut smegma spunk suicide tit tosser turd twat vagina wank whore wtf
xxx sexual sexily sexist sexing sexta sextet sexier sexton sextus
wessex sexism sussex sexes sexual""".split()
wessex sexism sussex sexes sexual rapist rape raped rapee rapes nude
nudist muff negro nazi nipple nudity lolita milf piss pissing porn
pron pube pubes barf""".split()
# Words that sound similar to others
HOMOPHONES = """there their than then hear here capital capitol won to too lose
@ -104,17 +106,20 @@ wile whine, wine whirl, whorl whirled, world whit, wit white, wight
who's, whose woe, whoa wood, would yaw, yore, your, you're yoke, yolk
you'll, yule""".replace(",", " ").lower().split()
HANDPICKED = """buttel buttle wholes""".lower().split()
HANDPICKED = """xxxiii buttel buttle wholes""".lower().split()
wnl = stem.WordNetLemmatizer()
REMOVE = HOMOPHONES + MORE_HOMOPHONES + RUDEWORDS
REMOVE = HOMOPHONES + MORE_HOMOPHONES + RUDEWORDS + HANDPICKED
REMOVE = set(wnl.lemmatize(R) for R in REMOVE)
for line in fileinput.input():
count, word = line.split()
word = word.lower()
if "xxx" in word:
continue
if word in REMOVE:
continue