dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

vocabulary.py (2567B)


      1 from talon import Context, Module
      2 from .user_settings import get_list_from_csv
      3 
      4 mod = Module()
      5 ctx = Context()
      6 
      7 mod.list("vocabulary", desc="additional vocabulary words")
      8 
      9 
     10 # Default words that will need to be capitalized (particularly under w2l).
     11 # NB. These defaults and those later in this file are ONLY used when
     12 # auto-creating the corresponding settings/*.csv files. Those csv files
     13 # determine the contents of user.vocabulary and dictate.word_map. Once they
     14 # exist, the contents of the lists/dictionaries below are irrelevant.
     15 _capitalize_defaults = [
     16     "I",
     17     "I'm",
     18     "I've",
     19     "I'll",
     20     "I'd",
     21     "Monday",
     22     "Mondays",
     23     "Tuesday",
     24     "Tuesdays",
     25     "Wednesday",
     26     "Wednesdays",
     27     "Thursday",
     28     "Thursdays",
     29     "Friday",
     30     "Fridays",
     31     "Saturday",
     32     "Saturdays",
     33     "Sunday",
     34     "Sundays",
     35     "January",
     36     "February",
     37     # March omitted because it's a regular word too
     38     "April",
     39     # May omitted because it's a regular word too
     40     "June",
     41     "July",
     42     "August",
     43     "September",
     44     "October",
     45     "November",
     46     "December",
     47 ]
     48 
     49 # Default words that need to be remapped.
     50 _word_map_defaults = {
     51     # E.g:
     52     # "cash": "cache",
     53 }
     54 _word_map_defaults.update({word.lower(): word for word in _capitalize_defaults})
     55 
     56 
     57 # "dictate.word_map" is used by `actions.dictate.replace_words` to rewrite words
     58 # Talon recognized. Entries in word_map don't change the priority with which
     59 # Talon recognizes some words over others.
     60 
     61 ctx.settings["dictate.word_map"] = get_list_from_csv(
     62     "words_to_replace.csv",
     63     headers=("Replacement", "Original"),
     64     default=_word_map_defaults,
     65 )
     66 
     67 
     68 # Default words that should be added to Talon's vocabulary.
     69 _simple_vocab_default = ["nmap", "admin", "Cisco", "Citrix", "VPN", "DNS", "Minecraft"]
     70 
     71 # Defaults for different pronounciations of words that need to be added to
     72 # Talon's vocabulary.
     73 _default_vocabulary = {
     74     "N map": "nmap",
     75     "under documented": "under-documented",
     76 }
     77 _default_vocabulary.update({word: word for word in _simple_vocab_default})
     78 
     79 # "user.vocabulary" is used to explicitly add words/phrases that Talon doesn't
     80 # recognize. Words in user.vocabulary (or other lists and captures) are
     81 # "command-like" and their recognition is prioritized over ordinary words.
     82 ctx.lists["user.vocabulary"] = get_list_from_csv(
     83     "additional_words.csv",
     84     headers=("Word(s)", "Spoken Form (If Different)"),
     85     default=_default_vocabulary,
     86 )
     87 
     88 # for quick verification of the reload
     89 # print(str(ctx.settings["dictate.word_map"]))
     90 # print(str(ctx.lists["user.vocabulary"]))