init commit
This commit is contained in:
@@ -0,0 +1,677 @@
|
||||
Aaron,Erin
|
||||
able,Abel
|
||||
acclamation,acclimation
|
||||
acts,ax
|
||||
Adam,atom
|
||||
add,ad
|
||||
addition,edition
|
||||
adds,ads,adz
|
||||
adduce,educe
|
||||
adherence,adherents
|
||||
ado,adieu
|
||||
aerial,ariel
|
||||
affected,effected
|
||||
afterward,afterword
|
||||
aid,aide
|
||||
air,heir,err
|
||||
ale,ail
|
||||
align,a line,aline
|
||||
all,awl
|
||||
allowed,aloud
|
||||
alluded,eluded
|
||||
alter,altar
|
||||
analyst,annalist
|
||||
appetite,apatite
|
||||
apprize,apprise
|
||||
arc,ark
|
||||
ascent,assent
|
||||
assistance,assistants
|
||||
attendance,attendants
|
||||
augur,auger
|
||||
aunt,ant
|
||||
away,aweigh
|
||||
axis,axes
|
||||
axle,axel
|
||||
Babel,babble
|
||||
bad,bade,bed
|
||||
bah,baa
|
||||
bail,bale,baal
|
||||
bait,bate
|
||||
baited,bated
|
||||
bald,balled,bawled
|
||||
ball,bawl
|
||||
band,banned
|
||||
baron,barren
|
||||
barred,bard
|
||||
barrel,beryl
|
||||
base,bass
|
||||
based,baste
|
||||
baseline,bassline
|
||||
basil,basal
|
||||
basis,bases
|
||||
basque,bask
|
||||
be,bee
|
||||
beach,beech
|
||||
bear,bare
|
||||
beat,beet
|
||||
been,bin
|
||||
beer,bier
|
||||
beetle,beatle
|
||||
bell,belle
|
||||
better,bettor
|
||||
bib,bibb
|
||||
bird,burred
|
||||
birth,berth
|
||||
bite,byte,bight
|
||||
bizarre,bazaar
|
||||
block,bloc
|
||||
blue,blew
|
||||
board,bored
|
||||
bold,bowled
|
||||
bomb,balm,bombe
|
||||
booty,bootie
|
||||
border,boarder
|
||||
bore,boar
|
||||
born,borne
|
||||
borough,burrow,burro
|
||||
bought,bot
|
||||
boulder,bolder
|
||||
bow,beau
|
||||
bow,bough
|
||||
bowed,bode
|
||||
boy,buoy
|
||||
braid,brayed
|
||||
brays,braise
|
||||
breach,breech
|
||||
bread,bred
|
||||
break,brake
|
||||
brewed,brood
|
||||
brews,bruise
|
||||
bridal,bridle
|
||||
broach,brooch
|
||||
browse,brows
|
||||
brute,brut
|
||||
build,billed
|
||||
bullion,bouillon,boolean
|
||||
burger,burgher
|
||||
bury,berry
|
||||
bust,bussed
|
||||
but,butt
|
||||
by,buy,bye
|
||||
cached,cashed
|
||||
caches,cashes
|
||||
caching,cashing
|
||||
caddy,caddie
|
||||
Cain,cane
|
||||
calendar,calender
|
||||
callous,callus
|
||||
cannon,canon
|
||||
cantor,canter
|
||||
canvas,canvass
|
||||
capital,capitol
|
||||
carol,carrel
|
||||
carrot,carat,caret,karat
|
||||
cash,cache
|
||||
cast,caste
|
||||
caster,castor
|
||||
cause,caws
|
||||
cedar,seeder
|
||||
ceiling,sealing
|
||||
chance,chants
|
||||
chased,chaste
|
||||
chauffeur,shofar
|
||||
cheap,cheep
|
||||
check,Czech
|
||||
chic,sheik
|
||||
Chile,chili,chilly
|
||||
choir,quire
|
||||
choose,chews
|
||||
cited,sided,sighted
|
||||
clack,claque
|
||||
clammer,clamor,clamber
|
||||
clause,claws
|
||||
click,clique
|
||||
climb,clime
|
||||
close,clothes,cloze
|
||||
clue,clew
|
||||
coal,cole
|
||||
coarser,courser
|
||||
coat,cote
|
||||
coax,cokes
|
||||
collared,collard
|
||||
complacent,complaisant
|
||||
complement,compliment
|
||||
conceded,conceited
|
||||
consonants,consonance
|
||||
consul,console,consol
|
||||
continents,continence
|
||||
cops,copse
|
||||
coral,choral
|
||||
cord,chord,cored
|
||||
core,corps
|
||||
coughers,coffers
|
||||
coulee,coolie
|
||||
council,counsel
|
||||
coup,coo
|
||||
coupe,coop
|
||||
course,coarse
|
||||
cousin,cozen
|
||||
coward,cowered
|
||||
coy,koi
|
||||
craft,kraft
|
||||
crawl,kraal
|
||||
creek,creak
|
||||
crepe,crape
|
||||
cruel,crewel
|
||||
cruise,crews
|
||||
current,currant
|
||||
cursor,curser
|
||||
Cyprus,cypress
|
||||
damn,dam
|
||||
Dane,deign
|
||||
days,daze
|
||||
dear,deer
|
||||
dense,dents
|
||||
descent,dissent
|
||||
die,dye
|
||||
diffused,defused
|
||||
discrete,discreet
|
||||
disperse,disburse
|
||||
do,dough,doe
|
||||
do,due,dew
|
||||
doc,dock
|
||||
does,doze
|
||||
done,dun
|
||||
draft,draught
|
||||
dual,duel
|
||||
ducked,duct
|
||||
ducks,ducts
|
||||
dying,dyeing
|
||||
earn,urn
|
||||
effect,affect
|
||||
effects,affects
|
||||
eight,ate
|
||||
eke,eek
|
||||
elude,allude
|
||||
elusive,illusive,allusive
|
||||
emend,amend
|
||||
end,and
|
||||
ensure,insure
|
||||
errant,arrant
|
||||
eve,eave
|
||||
exceed,accede
|
||||
except,accept
|
||||
excepting,accepting
|
||||
exercise,exorcise
|
||||
eyes,ayes
|
||||
facts,fax
|
||||
faint,feint
|
||||
fair,fare
|
||||
fairy,ferry
|
||||
fawn,faun
|
||||
feet,feat
|
||||
fens,fends
|
||||
fete,fate
|
||||
few,phew
|
||||
find,fined
|
||||
finish,Finnish
|
||||
fish,phish
|
||||
fished,phished
|
||||
fisher,fissure
|
||||
fishing,phishing
|
||||
flare,flair
|
||||
flee,flea
|
||||
flew,flu,flue
|
||||
flocks,phlox
|
||||
flow,floe
|
||||
flower,flour
|
||||
flyer,flier
|
||||
foe,faux
|
||||
fold,foaled
|
||||
for,four,fore
|
||||
foregone,forgone
|
||||
fort,forte
|
||||
forward,foreword
|
||||
foul,fowl
|
||||
fourth,forth
|
||||
frank,franc
|
||||
freeze,frees,frieze
|
||||
friar,fryer
|
||||
fur,fir
|
||||
gaffe,gaff
|
||||
gale,Gail
|
||||
gamble,gambol
|
||||
gate,gait
|
||||
gator,gaiter
|
||||
gauge,gage
|
||||
gel,jell
|
||||
gene,Jean
|
||||
gilder,guilder
|
||||
gnome,Nome
|
||||
gopher,gofer
|
||||
gorilla,guerilla
|
||||
gourd,gored
|
||||
grade,grayed
|
||||
graft,graphed
|
||||
graham,gram
|
||||
graze,grays
|
||||
great,grate
|
||||
greater,grater
|
||||
Greece,grease
|
||||
grill,grille
|
||||
grizzly,grisly
|
||||
grown,groan
|
||||
guest,guessed
|
||||
guild,gild
|
||||
guilt,gilt
|
||||
hail,hale
|
||||
hair,hare
|
||||
hall,haul
|
||||
handmade,handmaid
|
||||
handsome,hansom
|
||||
hangar,hanger
|
||||
have,halve
|
||||
haze,hays
|
||||
he'd,heed
|
||||
he'll,heal,heel
|
||||
heard,herd
|
||||
heart,hart
|
||||
here,hear
|
||||
heroin,heroine
|
||||
hey,hay
|
||||
high,hi
|
||||
higher,hire
|
||||
him,hymn
|
||||
ho,hoe
|
||||
hold,holed
|
||||
holy,wholly,holey
|
||||
hoop,whoop
|
||||
horde,hoard
|
||||
horse,hoarse
|
||||
hose,hoes
|
||||
hostile,hostel
|
||||
Hugh,hue,hew
|
||||
humorous,humerus
|
||||
hurts,hertz
|
||||
I,eye,aye
|
||||
I'd,eyed
|
||||
I'll,aisle,isle
|
||||
idle,idol,idyll
|
||||
illicit,elicit
|
||||
illusion,allusion
|
||||
imminent,immanent
|
||||
impassable,impassible
|
||||
in,inn
|
||||
innocence,innocents
|
||||
innumerable,enumerable
|
||||
insight,incite
|
||||
instance,instants
|
||||
intense,intents
|
||||
islet,eyelet
|
||||
its,it's
|
||||
jam,jamb
|
||||
jibe,gibe
|
||||
Jim,gym
|
||||
jinx,jinks
|
||||
json,jason
|
||||
kernel,colonel
|
||||
knickers,nickers
|
||||
knit,nit
|
||||
knock,nock
|
||||
knows,nose
|
||||
lacks,lax
|
||||
laid,lade
|
||||
lama,llama
|
||||
lane,lain
|
||||
laps,lapse,Lapps
|
||||
latter,ladder
|
||||
lay,lei
|
||||
lays,leis,laze
|
||||
leach,leech
|
||||
lead,led
|
||||
leak,leek
|
||||
lean,lien
|
||||
least,leased
|
||||
lee,lea
|
||||
lens,lends
|
||||
lesson,lessen
|
||||
let's,lets
|
||||
levy,levee
|
||||
liar,lyre,lier
|
||||
lie,lye
|
||||
light,lite
|
||||
liken,lichen
|
||||
links,lynx
|
||||
literal,littoral
|
||||
load,lode,lowed
|
||||
loan,lone
|
||||
loathe,loath
|
||||
loch,lock
|
||||
lochs,locks,lox
|
||||
loot,lute
|
||||
Lou,lieu
|
||||
low,lo
|
||||
lumber,lumbar
|
||||
made,maid
|
||||
main,Maine,mane
|
||||
male,mail
|
||||
mall,maul
|
||||
manner,manor
|
||||
mantle,mantel
|
||||
mark,marc
|
||||
martial,marshal
|
||||
martin,marten
|
||||
Mary,marry,merry
|
||||
mast,massed
|
||||
mat,matte
|
||||
matter,madder
|
||||
mayor,mare
|
||||
maze,maize
|
||||
mean,mien
|
||||
meet,meat,mete
|
||||
metal,medal,meddle,mettle
|
||||
meteor,meatier
|
||||
might,mite
|
||||
mill,mil
|
||||
mince,mints
|
||||
mind,mined
|
||||
minor,miner
|
||||
missed,mist
|
||||
missile,missal
|
||||
moan,mown
|
||||
moat,mote
|
||||
mode,mowed
|
||||
mood,mooed
|
||||
moose,mousse
|
||||
morning,mourning
|
||||
mourn,morn
|
||||
Mrs,misses
|
||||
mucus,mucous
|
||||
mule,mewl
|
||||
muscle,mussel
|
||||
muse,mews
|
||||
must,mussed
|
||||
mustard,mustered
|
||||
nap,knap
|
||||
naval,navel
|
||||
nave,knave
|
||||
nay,neigh
|
||||
need,knead,kneed
|
||||
new,knew,gnu
|
||||
nice,gneiss
|
||||
Nice,niece
|
||||
night,knight
|
||||
no,know
|
||||
none,nun
|
||||
not,knot
|
||||
oh,owe
|
||||
one,won
|
||||
or,ore,oar
|
||||
oral,aural
|
||||
oriole,aureole
|
||||
our,hour
|
||||
ours,hours
|
||||
outcast,outcaste
|
||||
overdue,overdo
|
||||
overseas,oversees
|
||||
owed,ode
|
||||
packed,pact
|
||||
paean,peon,paeon
|
||||
pain,pane
|
||||
pair,pear,pare
|
||||
pale,pail
|
||||
palette,palate,pallet
|
||||
parish,perish
|
||||
parley,parlay
|
||||
past,passed
|
||||
paste,paced
|
||||
patients,patience
|
||||
patted,padded
|
||||
Paul,pall
|
||||
pause,paws
|
||||
peak,peek,pique
|
||||
peas,pees
|
||||
pedal,peddle,petal
|
||||
pee,pea
|
||||
peel,peal
|
||||
peer,pier
|
||||
penance,pennants
|
||||
per,purr
|
||||
perl,pearl,purl
|
||||
pervade,purveyed
|
||||
Pete,peat
|
||||
petrol,petrel
|
||||
pew,pugh
|
||||
phase,faze
|
||||
Phil,fill
|
||||
phrase,frays
|
||||
picot,pekoe
|
||||
pie,pi
|
||||
piece,peace
|
||||
pigeon,pidgin
|
||||
pilot,Pilate
|
||||
pistol,pistil
|
||||
plane,plain
|
||||
plaque,plack
|
||||
plate,plait
|
||||
please,pleas
|
||||
plum,plumb
|
||||
poll,pole
|
||||
pour,pore
|
||||
praise,prays,preys
|
||||
pray,prey
|
||||
precedence,precedents
|
||||
premier,premiere
|
||||
presence,presents
|
||||
pride,pried
|
||||
primer,primmer
|
||||
prince,prints
|
||||
principle,principal
|
||||
profit,prophet
|
||||
pros,prose
|
||||
pull,pool
|
||||
quartz,quarts
|
||||
queue,cue
|
||||
queues,cues
|
||||
quince,quints
|
||||
rabbit,rabbet
|
||||
rack,wrack
|
||||
rain,reign,rein
|
||||
raise,rays,raze
|
||||
read,red
|
||||
read,reed
|
||||
real,reel
|
||||
residents,residence
|
||||
rest,wrest
|
||||
review,revue
|
||||
right,write,rite
|
||||
rights,writes,rites
|
||||
rigor,rigger
|
||||
ring,wring
|
||||
road,rode,rowed
|
||||
roads,rhodes
|
||||
role,roll
|
||||
Rome,roam
|
||||
room,rheum
|
||||
rose,rows
|
||||
rot,wrought
|
||||
rough,ruff
|
||||
route,root
|
||||
row,roe
|
||||
rude,rued
|
||||
rue,roux
|
||||
rumor,roomer
|
||||
rung,wrung
|
||||
Russell,rustle
|
||||
rye,wry
|
||||
sachet,sashay
|
||||
sack,sac
|
||||
sacks,sax
|
||||
sale,sail
|
||||
sane,seine
|
||||
saver,savor
|
||||
scalar,scaler
|
||||
see,sea
|
||||
seed,cede
|
||||
seem,seam
|
||||
seen,scene
|
||||
seer,sear,sere
|
||||
sees,seize,seas
|
||||
sell,cell
|
||||
seller,cellar
|
||||
sense,cents,scents
|
||||
sensor,censor
|
||||
sent,cent,scent
|
||||
serial,cereal
|
||||
series,Ceres
|
||||
session,cession
|
||||
sewing,sowing
|
||||
sheer,shear
|
||||
shoe,shoo
|
||||
shoot,chute
|
||||
shown,shone
|
||||
sick,sic
|
||||
side,sighed
|
||||
signet,cygnet
|
||||
sink,sync
|
||||
sinking,syncing
|
||||
site,sight,cite
|
||||
size,sighs
|
||||
skull,scull
|
||||
slay,sleigh
|
||||
slew,slough,slue
|
||||
slight,sleight
|
||||
slow,sloe
|
||||
so,sow,sew
|
||||
sold,soled
|
||||
some,sum
|
||||
son,sun
|
||||
sore,soar
|
||||
sorry,sari
|
||||
soul,sole
|
||||
spade,spayed
|
||||
stake,steak
|
||||
stare,stair
|
||||
stationary,stationery
|
||||
stayed,staid
|
||||
steel,steal
|
||||
step,steppe
|
||||
straight,strait
|
||||
straightened,straitened
|
||||
style,stile
|
||||
sue,Sioux
|
||||
suit,soot
|
||||
summary,summery
|
||||
Sunday,sundae
|
||||
surf,serf
|
||||
surge,serge
|
||||
swayed,suede
|
||||
sweet,suite
|
||||
sword,soared
|
||||
symbol,cymbal
|
||||
tacked,tact
|
||||
tale,tail
|
||||
talk,tock
|
||||
taper,tapir
|
||||
taught,taut
|
||||
taupe,tope
|
||||
tax,tacks
|
||||
tea,tee
|
||||
team,teem
|
||||
tear,tare
|
||||
tear,tier
|
||||
tease,teas,tees
|
||||
tens,tends
|
||||
tense,tents
|
||||
terry,tarry
|
||||
than,then
|
||||
the,thee
|
||||
their,there,they're
|
||||
there's,theirs
|
||||
through,threw
|
||||
thrown,throne
|
||||
throws,throes
|
||||
tick,tic
|
||||
tie,Thai
|
||||
tied,tide
|
||||
Tigris,tigress
|
||||
timber,timbre
|
||||
time,thyme
|
||||
to,two,too
|
||||
toe,tow
|
||||
told,tolled
|
||||
tool,tulle
|
||||
tort,torte
|
||||
torturous,tortuous
|
||||
towed,toad,toed
|
||||
tracked,tract
|
||||
trader,traitor
|
||||
troop,troupe
|
||||
trust,trussed
|
||||
tucks,tux
|
||||
turbine,turban
|
||||
turn,tern
|
||||
tutor,Tudor,tooter
|
||||
undo,undue
|
||||
use,ewes,yews
|
||||
utter,udder
|
||||
vain,vein,vane
|
||||
valence,valance
|
||||
variants,variance
|
||||
veil,vale
|
||||
vein,vane
|
||||
Venus,venous
|
||||
versus,verses
|
||||
very,vary
|
||||
vice,vise
|
||||
vile,vial
|
||||
wade,weighed
|
||||
wait,weight
|
||||
waiter,wader
|
||||
Wales,whales,wails
|
||||
walk,wok
|
||||
want,wont
|
||||
war,wore
|
||||
ward,word
|
||||
waste,waist
|
||||
wave,waive
|
||||
wax,whacks
|
||||
way,weigh,whey
|
||||
Wayne,wane,wain
|
||||
ways,weighs
|
||||
we,wee
|
||||
we'd,weed
|
||||
we'll,wheel
|
||||
we've,weave
|
||||
wears,where's,wares
|
||||
week,weak
|
||||
weekly,weakly
|
||||
were,whir,we're
|
||||
wet,whet
|
||||
whale,wail,wale
|
||||
wheeled,wield
|
||||
where,wear,ware
|
||||
whether,weather,wether
|
||||
whether,weather
|
||||
which,witch
|
||||
while,wile
|
||||
whoa,woe
|
||||
whole,hole
|
||||
whose,who's
|
||||
wind,whined,wined
|
||||
wine,whine
|
||||
with,width
|
||||
word,whirred
|
||||
world,whirled,whorled
|
||||
worn,warn
|
||||
would,wood
|
||||
wrap,rap
|
||||
wrapped,rapped,rapt
|
||||
wrapper,rapper
|
||||
wreak,reek
|
||||
wretch,retch
|
||||
wrote,rote
|
||||
yoke,yolk
|
||||
you,yew,ewe
|
||||
you'll,Yule
|
||||
your,you're,yore
|
||||
|
@@ -0,0 +1,243 @@
|
||||
import os
|
||||
|
||||
from talon import Context, Module, actions, app, clip, fs, imgui, ui
|
||||
|
||||
########################################################################
|
||||
# global settings
|
||||
########################################################################
|
||||
|
||||
# a list of homophones where each line is a comma separated list
|
||||
# e.g. where,wear,ware
|
||||
# a suitable one can be found here:
|
||||
# https://github.com/pimentel/homophones
|
||||
cwd = os.path.dirname(os.path.realpath(__file__))
|
||||
homophones_file = os.path.join(cwd, "homophones.csv")
|
||||
# if quick_replace, then when a word is selected and only one homophone exists,
|
||||
# replace it without bringing up the options
|
||||
quick_replace = True
|
||||
show_help = False
|
||||
########################################################################
|
||||
|
||||
ctx = Context()
|
||||
mod = Module()
|
||||
|
||||
mod.list("homophones_canonicals", desc="list of words ")
|
||||
mod.tag(
|
||||
"homophones_open",
|
||||
desc="Tag for enabling homophones commands when the associated gui is open",
|
||||
)
|
||||
|
||||
main_screen = ui.main_screen()
|
||||
|
||||
|
||||
def update_homophones(name, flags):
|
||||
if name != homophones_file:
|
||||
return
|
||||
|
||||
phones = {}
|
||||
canonical_list = []
|
||||
with open(homophones_file) as f:
|
||||
for line in f:
|
||||
words = line.rstrip().split(",")
|
||||
words = [x for x in words if x.strip() != ""]
|
||||
canonical_list.append(words[0])
|
||||
merged_words = set(words)
|
||||
for word in words:
|
||||
old_words = phones.get(word.lower(), [])
|
||||
merged_words.update(old_words)
|
||||
merged_words = sorted(merged_words)
|
||||
for word in merged_words:
|
||||
phones[word.lower()] = merged_words
|
||||
|
||||
global all_homophones
|
||||
all_homophones = phones
|
||||
ctx.lists["self.homophones_canonicals"] = canonical_list
|
||||
|
||||
|
||||
update_homophones(homophones_file, None)
|
||||
fs.watch(cwd, update_homophones)
|
||||
active_word_list = None
|
||||
is_selection = False
|
||||
|
||||
|
||||
def close_homophones():
|
||||
gui.hide()
|
||||
ctx.tags = []
|
||||
|
||||
|
||||
PHONES_FORMATTERS = [
|
||||
lambda word: word.capitalize(),
|
||||
lambda word: word.upper(),
|
||||
]
|
||||
|
||||
|
||||
def find_matching_format_function(word_with_formatting, format_functions):
|
||||
"""Finds the formatter function from a list of formatter functions which transforms a word into itself.
|
||||
Returns an identity function if none exists"""
|
||||
for formatter in format_functions:
|
||||
formatted_word = formatter(word_with_formatting)
|
||||
if word_with_formatting == formatted_word:
|
||||
return formatter
|
||||
|
||||
return lambda word: word
|
||||
|
||||
|
||||
def raise_homophones(word_to_find_homophones_for, forced=False, selection=False):
|
||||
global quick_replace
|
||||
global active_word_list
|
||||
global show_help
|
||||
global force_raise
|
||||
global is_selection
|
||||
|
||||
force_raise = forced
|
||||
is_selection = selection
|
||||
|
||||
if is_selection:
|
||||
word_to_find_homophones_for = word_to_find_homophones_for.strip()
|
||||
formatter = find_matching_format_function(
|
||||
word_to_find_homophones_for, PHONES_FORMATTERS
|
||||
)
|
||||
|
||||
word_to_find_homophones_for = word_to_find_homophones_for.lower()
|
||||
|
||||
# We support plurals, but very naively. If we can't find your word but your word ends in an s, presume its plural
|
||||
# and attempt to find the singular, then present the presumed plurals back. This could be improved!
|
||||
if word_to_find_homophones_for in all_homophones:
|
||||
valid_homophones = all_homophones[word_to_find_homophones_for]
|
||||
elif (
|
||||
word_to_find_homophones_for.endswith("s")
|
||||
and word_to_find_homophones_for[:-1] in all_homophones
|
||||
):
|
||||
valid_homophones = map(
|
||||
lambda w: w + "s", all_homophones[word_to_find_homophones_for[:-1]]
|
||||
)
|
||||
else:
|
||||
app.notify(
|
||||
"homophones.py", f'"{word_to_find_homophones_for}" not in homophones list'
|
||||
)
|
||||
return
|
||||
|
||||
# Move current word to end of list to reduce searcher's cognitive load
|
||||
valid_homophones_reordered = list(
|
||||
filter(
|
||||
lambda word_from_list: word_from_list.lower()
|
||||
!= word_to_find_homophones_for,
|
||||
valid_homophones,
|
||||
)
|
||||
) + [word_to_find_homophones_for]
|
||||
active_word_list = list(map(formatter, valid_homophones_reordered))
|
||||
|
||||
if (
|
||||
is_selection
|
||||
and len(active_word_list) == 2
|
||||
and quick_replace
|
||||
and not force_raise
|
||||
):
|
||||
if word_to_find_homophones_for == active_word_list[0].lower():
|
||||
new = active_word_list[1]
|
||||
else:
|
||||
new = active_word_list[0]
|
||||
|
||||
clip.set(new)
|
||||
actions.edit.paste()
|
||||
return
|
||||
|
||||
ctx.tags = ["user.homophones_open"]
|
||||
show_help = False
|
||||
gui.show()
|
||||
|
||||
|
||||
@imgui.open(x=main_screen.x + main_screen.width / 2.6, y=main_screen.y)
|
||||
def gui(gui: imgui.GUI):
|
||||
global active_word_list
|
||||
if show_help:
|
||||
gui.text("Homophone help - todo")
|
||||
else:
|
||||
gui.text("Select a homophone")
|
||||
gui.line()
|
||||
index = 1
|
||||
for word in active_word_list:
|
||||
if gui.button(f"Choose {index}: {word}"):
|
||||
actions.insert(actions.user.homophones_select(index))
|
||||
actions.user.homophones_hide()
|
||||
index = index + 1
|
||||
|
||||
if gui.button("Phones (hide | exit)"):
|
||||
actions.user.homophones_hide()
|
||||
|
||||
|
||||
def show_help_gui():
|
||||
global show_help
|
||||
show_help = True
|
||||
gui.show()
|
||||
|
||||
|
||||
@mod.capture(rule="{self.homophones_canonicals}")
|
||||
def homophones_canonical(m) -> str:
|
||||
"Returns a single string"
|
||||
return m.homophones_canonicals
|
||||
|
||||
|
||||
@mod.action_class
|
||||
class Actions:
|
||||
def homophones_hide():
|
||||
"""Hides the homophones display"""
|
||||
close_homophones()
|
||||
|
||||
def homophones_show(m: str):
|
||||
"""Show the homophones display"""
|
||||
raise_homophones(m, False, False)
|
||||
|
||||
def homophones_show_auto():
|
||||
"""Show homophones for selection, or current word if selection is empty."""
|
||||
text = actions.edit.selected_text()
|
||||
if text:
|
||||
raise_homophones(text, False, True)
|
||||
else:
|
||||
actions.edit.select_word()
|
||||
actions.user.homophones_show_selection()
|
||||
|
||||
def homophones_show_selection():
|
||||
"""Show the homophones display for the selected text"""
|
||||
raise_homophones(actions.edit.selected_text(), False, True)
|
||||
|
||||
def homophones_force_show(m: str):
|
||||
"""Show the homophones display forcibly"""
|
||||
raise_homophones(m, True, False)
|
||||
|
||||
def homophones_force_show_selection():
|
||||
"""Show the homophones display for the selected text forcibly"""
|
||||
raise_homophones(actions.edit.selected_text(), True, True)
|
||||
|
||||
def homophones_select(number: int) -> str:
|
||||
"""selects the homophone by number"""
|
||||
if number <= len(active_word_list) and number > 0:
|
||||
return active_word_list[number - 1]
|
||||
|
||||
error = "homophones.py index {} is out of range (1-{})".format(
|
||||
number, len(active_word_list)
|
||||
)
|
||||
app.notify(error)
|
||||
raise error
|
||||
|
||||
def homophones_get(word: str) -> [str] or None:
|
||||
"""Get homophones for the given word"""
|
||||
word = word.lower()
|
||||
if word in all_homophones:
|
||||
return all_homophones[word]
|
||||
return None
|
||||
|
||||
|
||||
ctx_homophones_open = Context()
|
||||
ctx_homophones_open.matches = """
|
||||
tag: user.homophones_open
|
||||
"""
|
||||
|
||||
|
||||
@ctx_homophones_open.action_class("user")
|
||||
class UserActions:
|
||||
def choose(number_small: int):
|
||||
"""Choose the nth homophone"""
|
||||
result = actions.user.homophones_select(number_small)
|
||||
actions.insert(result)
|
||||
actions.user.homophones_hide()
|
||||
@@ -0,0 +1,19 @@
|
||||
phones <user.homophones_canonical>: user.homophones_show(homophones_canonical)
|
||||
phones that: user.homophones_show_auto()
|
||||
phones force <user.homophones_canonical>:
|
||||
user.homophones_force_show(homophones_canonical)
|
||||
phones force: user.homophones_force_show_selection()
|
||||
phones (hide | exit): user.homophones_hide()
|
||||
phones word:
|
||||
edit.select_word()
|
||||
user.homophones_show_selection()
|
||||
phones [<user.ordinals>] word left:
|
||||
n = ordinals or 1
|
||||
user.words_left(n - 1)
|
||||
edit.extend_word_left()
|
||||
user.homophones_show_selection()
|
||||
phones [<user.ordinals>] word right:
|
||||
n = ordinals or 1
|
||||
user.words_right(n - 1)
|
||||
edit.extend_word_right()
|
||||
user.homophones_show_selection()
|
||||
@@ -0,0 +1,7 @@
|
||||
tag: user.homophones_open
|
||||
-
|
||||
|
||||
choose <user.formatters> <number_small>:
|
||||
result = user.homophones_select(number_small)
|
||||
insert(user.formatted_text(result, formatters))
|
||||
user.homophones_hide()
|
||||
Reference in New Issue
Block a user