<p>Automatic Program Repair (APR) can reduce the effort required to identify and correct programming errors. This study proposes <i>PySynFix</i>, a computationally lightweight APR system for Python syntax error correction. The system uses a Bidirectional Long Short-Term Memory (BiLSTM) network for multi-class error classification and a Long Short-Term Memory (LSTM) network for token-level repair, supported by hybrid fault localization based on Abstract Syntax Tree parsing and Microsoft’s Pyright tool. Trained on 6,000 synthetically generated faulty samples, <i>PySynFix</i> achieved 98% classification accuracy and 98.44% token-correction accuracy with a 98.91% F1 score. On the proposed test dataset, it repaired 794 out of 925 faulty cases (85.84%), outperforming the rule-based PyNar system (52.3%). On an IBM CodeNet-derived benchmark, <i>PySynFix</i> achieved a 59.2% repair success rate, compared with 25.17% for PyNar under the same category setup. Additional zero-shot experiments with Qwen3-Coder achieved 84.33–88.67% repair rates on token-level errors and 80.00% on indentation errors in the proposed dataset, as well as an overall repair rate of 71.83% on the same 600-case IBM-derived setup. Computational-footprint experiments showed that <i>PySynFix</i> requires substantially fewer parameters and lower inference-time resources than representative transformer-based code models. The evaluation focuses on syntactic validity rather than semantic equivalence, positioning <i>PySynFix</i> as a task-specific and resource-efficient solution for Python syntax repair.</p>

错误:搜索内容不能为空,请输入英文关键词
错误:关键词超出字数限制,请精简
高级检索

BiLSTM and LSTM networks: an efficient alternative to large language models for python syntax error correction

  • Sena Dikici,
  • Turgay Tugay Bilgin

摘要

Automatic Program Repair (APR) can reduce the effort required to identify and correct programming errors. This study proposes PySynFix, a computationally lightweight APR system for Python syntax error correction. The system uses a Bidirectional Long Short-Term Memory (BiLSTM) network for multi-class error classification and a Long Short-Term Memory (LSTM) network for token-level repair, supported by hybrid fault localization based on Abstract Syntax Tree parsing and Microsoft’s Pyright tool. Trained on 6,000 synthetically generated faulty samples, PySynFix achieved 98% classification accuracy and 98.44% token-correction accuracy with a 98.91% F1 score. On the proposed test dataset, it repaired 794 out of 925 faulty cases (85.84%), outperforming the rule-based PyNar system (52.3%). On an IBM CodeNet-derived benchmark, PySynFix achieved a 59.2% repair success rate, compared with 25.17% for PyNar under the same category setup. Additional zero-shot experiments with Qwen3-Coder achieved 84.33–88.67% repair rates on token-level errors and 80.00% on indentation errors in the proposed dataset, as well as an overall repair rate of 71.83% on the same 600-case IBM-derived setup. Computational-footprint experiments showed that PySynFix requires substantially fewer parameters and lower inference-time resources than representative transformer-based code models. The evaluation focuses on syntactic validity rather than semantic equivalence, positioning PySynFix as a task-specific and resource-efficient solution for Python syntax repair.