Teaching ChatGPT to read code context makes it expand abbreviations like a pro. This paper explores this area in depth.
ChatGPT + smart context = state-of-art code abbreviation expansion without parsing headaches
https://arxiv.org/abs/2410.23866
π― Original Problem:
Source code abbreviations reduce readability and hinder maintenance. While several approaches exist to expand these abbreviations, none leverage LLMs, which have shown remarkable success in various software engineering tasks.
-----
π οΈ Methods discussed in this Paper:
β Used ChatGPT to expand source code abbreviations through few-shot prompting
β Enhanced context awareness by incorporating surrounding code (3 lines before/after)
β Implemented iterative marking to identify missed abbreviations
β Added post-condition checking to filter incorrect expansions
β Built a system that matches state-of-the-art accuracy without requiring expensive code parsing
-----
π‘ Key Insights:
β ChatGPT initially performs poorly compared to specialized tools, with 28.2% lower precision
β Surrounding code context outperforms both knowledge graphs and enclosing files
β 53% of missed abbreviations get correctly expanded after explicit marking
β Simple post-condition checking improves precision by 2 percentage points
-----
π Results:
β Base ChatGPT: 64% precision, 61% recall
β With surrounding code: 89% precision, 87% recall
β Final system matches tfExpander's 92% precision, 89% recall
β Works even with compilation errors, unlike traditional approaches










