Skip to content

abbreviate

The community/core/abbreviate directory contains a single file, abbreviate.py. This file defines a system for expanding abbreviations in Talon. It works by defining a list of common abbreviations and their expansions, and then creating a Talon list that can be used in voice commands.

Here's a breakdown of how it works:

  • Abbreviations List: The core of this file is the abbreviations dictionary, which maps spoken forms (e.g., "application") to their abbreviated forms (e.g., "app"). This dictionary is quite extensive, covering common terms from programming, technology, and general usage.
  • Talon Module and Context: The file sets up a Talon module and context. This allows the definitions in the file to be used by Talon voice commands. The line mod.list("abbreviation", desc="Common abbreviation") declares a list that can be referenced in other Talon files.
  • track_csv_list Decorator: The @track_csv_list decorator loads abbreviations from a CSV file named abbreviations.csv. This CSV file allows users to customize the abbreviations. The decorator takes a default dictionary, which is the abbreviations dictionary defined in the file.
  • Loading Abbreviations: The on_abbreviations function is called when the CSV file is loaded or changed. It updates a global dictionary abbreviations_list, and adds both the spoken and abbreviated forms to the Talon list user.abbreviation.
  • Capture Rule: The file defines a capture rule brief {user.abbreviation} that allows any abbreviation in the user.abbreviation list to be captured by a voice command that uses the term "brief."
  • Usage: With this configuration, a Talon user can say "brief app" and it would expand to "app", or "brief application" which would also expand to "app". Similarly "brief address" would be "addr" and "brief addresses" would be "addrs".

In short, abbreviate.py provides a system for creating and using short forms for common words and phrases, which can speed up dictation by requiring less verbal communication from the user.