stata
This directory provides Talon voice command and syntax support for the Stata statistical programming language. By combining configuration mappings, custom action implementations, and a list of common Stata commands, it allows developers to write Stata code and run statistical commands entirely by voice.
How Stata Support Works
The support is built using three cooperating files:
- stata.talon acts as the entry point, defining the syntax voice commands and activating universal coding tags when a
.statafile is open. - stata.py acts as the backend handler. It configures the abstract syntax tags (like operators and functions) into actual Stata-specific syntax and implements the mechanics of inserting library imports and program blocks.
- code_common_function.talon-list registers a dictionary of frequently used Stata operations and package wrappers to make them easily dictatable.
Key Components
stata.talon
This file targets active files with the stata language code. It performs the following setup:
- Syntax Tagging: Enables standardized coding behaviors such as imperative programming structures (
user.code_imperative), comment blocks, standard operators, functions, and library management. - Settings: Instructs the formatter to output private functions in
SNAKE_CASE(consistent with typical Stata program naming conventions). - Custom Snippets and Commands:
- Maps the word
argto insert standard statistical options like standard error cluster parameters. - Maps
state for valto quickly spit out a Stataforloop template. - Provides quick phrases to install packages via SSC (e.g.,
s s c install estoutvias s c install <user.code_libraries>).
- Maps the word
stata.py
This Python module defines the context matches for Stata files and overrides the default coding actions to produce Stata-specific text:
- Operator Mapping: Defines symbols and formatting for common mathematical and assignment operations. For example, the modulo operator
%is mapped to the functionalmod(x, y)syntax, and standard logical and arithmetic operators (==,!=,&,|) are defined. - Parameters & Libraries: Registers lists of parameters—such as variance-covariance estimators (
vce(cluster)andvce(robust))—and popular external libraries likeestout. - Program & Function Structuring: Overrides standard function-creation actions. Creating a private function by voice translates into a Stata
program ... endblock, positioning the cursor correctly inside the body of the program.
code_common_function.talon-list
This list contains short, recognizable spoken names mapped to their corresponding Stata commands. It includes:
- Core commands:
global,local, andregress/reg. - Package-specific helpers: Contains support for the widely used
estoutsuite (estadd,estout,estpost,eststo,esttab), which is the standard toolset for formatting and exporting regression tables in Stata.