Introduction
Spreadsheet users frequently encounter data-cleaning tasks that are too complex for simple "Find and Replace" but too niche to justify writing custom macros or scripts. While tools like Excel's Flash Fill have successfully automated syntactic transformations—patterns based on character positions and regular expressions—they often fail when the transformation requires semantic knowledge. This paper presents a "Programming by Example" (PBE) framework that bridges this gap by learning transformations that combine text manipulation with relational table lookups.
The Challenge: Beyond Syntactic Patterns
A semantic transformation is one where the output depends on external information not present in the input string itself. For instance, converting a product name into a markup price requires the system to "understand" the relationship by looking up the product in a separate price table. The challenge lies in synthesizing a program that performs these lookups and manipulations automatically, efficiently, and with minimal user input.
Methodology
The authors introduce a domain-specific language (DSL), denoted as $L_u$, which integrates two sub-languages: $L_t$ for table lookups and $L_s$ for syntactic manipulations. This hybrid approach allows for nested operations, such as using a substring of a lookup result as a key for a subsequent lookup.
Relational Tables and Background Knowledge
For semantic tasks, the system relies on relational tables provided within the spreadsheet or as external background knowledge (e.g., mapping month names to numbers). These tables allow the synthesis engine to resolve dependencies that are otherwise invisible to purely syntactic models.
Synthesis and Representation
To manage the millions of possible programs that might satisfy a single example, the authors utilize a specialized Directed Acyclic Graph (DAG) to represent the "version space" of programs. This allows for the storage of an exponential number of programs in polynomial space. The synthesis algorithm employs iterative forward-reachability analysis, starting from input strings and applying rules to reach the desired output. To ensure generalization, the system ranks consistent programs using Occam’s Razor, preferring smaller programs with fewer constants.
Key Results
The framework was evaluated on 50 benchmarks sourced from real-world help forums and internal Microsoft teams. The results demonstrate high efficiency and usability:
- Speed: 88% of benchmarks were solved in less than one second, and 96% in under two seconds.
- User Effort: 35 out of 50 tasks required only a single example to produce the correct result. No task required more than three examples.
- Complexity: The system successfully handled complex "join" scenarios, such as looking up a price based on a combination of an item ID and a formatted date string.
Conclusion and Future Work
By treating table lookups as a first-class transformation type, this framework provides a unified solution for both text editing and database-driven data cleaning. While highly effective for typical spreadsheet scales, future work aims to optimize the reachability analysis for extremely large databases and to better handle "infinite domain" transformations like complex mathematical rounding that are not easily tabulated.
Summary updated