A Bidirectional LSTM Language Model for Code Evaluation and Repair
Abstract
:1. Introduction
#include <stdio.h> |
int main(){ |
int j, l, totalsum = 0; |
printf(“Give a number: “); |
scanf(“%d”, &l); |
for (j = 1; j < = l; j++){ |
totalsum = totalsum + j; |
} |
printf(“Total sum of 1 to %d is: %d\n”, l, totalsum); |
return (0); |
} |
#include <stdio.h> |
int main(){ |
int j, l, totalsum = 0; |
printf(“Give a number: “); |
scanf(“%d”, &l); |
for (j = 1; j < l; j++){ |
Totalsum = totalsum + j; |
} |
printf(“Total sum of 1 to %d is: %d\n”, l, totalsum); |
return (0); |
} |
- The proposed BiLSTM language model for code evaluation and repair can effectively detect errors (including logical errors) and suggest corrections for incorrect code.
- Application of the proposed model to real-world solution codes collected from the Aizu Online Judge (AOJ) system produced experimental results that indicate superior performance in comparison to other approaches.
- The BiLSTM model can be helpful to students, programmers (especially novice programmers), and professionals, who often struggle to resolve code errors.
- The model accelerates the code evaluation process.
- The proposed model can be used for different real-world programming learning and software engineering related systems and services.
2. Related Works
3. Proposed Approach
3.1. BiLSTM Model Architecture
3.2. Data Collection and Preprocessing
4. Experimental Results
4.1. Data and Experimental Setup
4.2. Evaluation Metrics
4.3. Cross-Entropy
4.4. Determining the Number of Epochs and Hidden Units
4.5. Incorrect Source Code Evaluation
4.6. Suggestions for Code Repair
4.7. Error Detection Performance
5. Limitations
6. Conclusions
Author Contributions
Funding
Institutional Review Board Statement
Informed Consent Statement
Data Availability Statement
Conflicts of Interest
References
- Vee, A. Understanding Computer Programming as a Literacy. LICS Lit. Compos. Stud. 2013, 1, 42–64. [Google Scholar] [CrossRef]
- Revilla, M.A.; Manzoor, S.; Liu, R. Competitive learning in informatics: The UVa online judge experience. Olymp. Inform. 2008, 2, 131–148. [Google Scholar]
- Petit, J.; Roura, S.; Carmona, J.; Cortadella, J.; Duch, J.; Gimnez, O.; Mani, A.; Mas, J.; Rodrguez-Carbonell, E.; Rubio, E.; et al. Jutge.org: Characteristics and Experiences. IEEE Trans. Learn. Technol. 2018, 11, 321–333. [Google Scholar] [CrossRef] [Green Version]
- Bez, J.L.; Tonin, N.A.; Rodegheri, P.R. URI Online Judge Academic: A tool for algorithms and programming classes. In Proceedings of the 2014 9th International Conference on Computer Science Education, Vancouver, BC, Canada, 22–24 August 2014; pp. 149–152. [Google Scholar] [CrossRef]
- Watanobe, Y. Aizu Online Judge. Available online: https://onlinejudge.u-aizu.ac.jp (accessed on 20 October 2020).
- Mekterović, I.; Brkić, L.; Milašinović, B.; Baranović, M. Building a comprehensive automated programming assessment system. IEEE Access 2020, 8, 81154–81172. [Google Scholar] [CrossRef]
- Ghassan, S. A Practical Approach for Detecting Logical Error in Object Oriented Environment. World Comput. Sci. Inf. Technol. J. 2017, 7, 10–19. [Google Scholar]
- Al-Ashwal, D.; Al-Sewari, E.Z.; Al-Shargabi, A.A. A CASE Tool for JAVA Programs Logical Errors Detection: Static and Dynamic Testing. In Proceedings of the 2018 International Arab Conference on Information Technology (ACIT), Werdanye, Lebanon, 28–30 November 2018; pp. 1–6. [Google Scholar]
- Seo, H.; Sadowski, C.; Elbaum, S.; Aftandilian, E.; Bowdidge, R. Programmers’ build errors: A case study (at google). In Proceedings of the 36th International Conference on Software Engineering (ICSE’14), Hyderabad, India, 31 May–7 June 2014; pp. 724–734. [Google Scholar]
- Minku, L.L.; Mendes, E.; Turhan, B. Data mining for software engineering and humans in the loop. Progress Artif. Intell. 2016, 5, 307–314. [Google Scholar] [CrossRef] [Green Version]
- Monperrus, M. Automatic software repair: A bibliography. ACM Comput. Surv. 2018, 51, 1–24. [Google Scholar] [CrossRef] [Green Version]
- Frantzeskou, G.; MacDonell, S.; Stamatatos, E.; Gritzalis, S. Examining the significance of high-level programming features in source code author classification. J. Syst. Softw. 2008, 81, 447–460. [Google Scholar] [CrossRef] [Green Version]
- Mou, L.; Li, G.; Zhang, L.; Wang, T.; Jin, Z. Convolutional neural networks over tree structures for programming language processing. In Proceedings of the Thirtieth AAAI Conference on Artificial Intelligence, Phoenix, AZ, USA, 12–17 February 2016; pp. 1287–1293. [Google Scholar]
- White, M.; Tufano, M.; Vendome, C.; Poshyvanyk, D. Deep learning code fragments for code clone detection. In Proceedings of the 31st IEEE/ACM International Conference on Automated Software Engineering, Singapore, 3–7 September 2016; pp. 87–98. [Google Scholar]
- Wei, H.H.; Li, M. Supervised deep features for software functional clone detection by exploiting lexical and syntactical information in source code. In Proceedings of the 26th International Joint Conference on Artificial Intelligence, Melbourne, VIC, Australia, 19–25 August 2017; pp. 3034–3040. [Google Scholar]
- D’Ambros, M.; Lanza, M.; Robbes, R. Evaluating defect prediction approaches: A benchmark and an extensive comparison. Empir. Softw. Eng. 2012, 17, 531–577. [Google Scholar] [CrossRef]
- Pu, Y.; Narasimhan, K.; Solar-Lezama, A.; Barzilay, R. Sk_p: A neural program corrector for mooc. In Proceedings of the 2016 ACM SIGPLAN International Conference on Systems, Programming, Languages and Applications: Software for Humanity, Amsterdam, The Netherlands, 20 October 2016; pp. 39–40. [Google Scholar]
- Gupta, R.; Pal, S.; Kanade, A.; Shevade, S.K. DeepFix: Fixing common c language errors by deep learning. In Proceedings of the Thirty-First AAAI Conference on Artificial Intelligence (AAAI-17), San Francisco, CA, USA, 4–9 February 2017; pp. 1345–1351. [Google Scholar]
- Raychev, V.; Vechev, M.; Yahav, E. Code completion with statistical language models. In Proceedings of the 35th ACM SIGPLAN Conference on Programming Language Design and Implementation, PLDI’14, Edinburgh, UK, 9–11 June 2014; pp. 419–428. [Google Scholar]
- Rahman, M.M.; Watanobe, Y.; Nakamura, K. A Neural Network Based Intelligent Support Model for Program Code Completion. Sci. Program. 2020, 2020, 7426461. [Google Scholar] [CrossRef]
- Pennington, J.; Socher, R.; Manning, C.D. Glove: Global vectors for word representation. In Proceedings of the 2014 Conference on Empirical Methods in Natural Language Processing (EMNLP), Doha, Qatar, 25–29 October 2014; pp. 1532–1543. [Google Scholar]
- Teshima, Y.; Watanobe, Y. Bug detection based on LSTM networks and solution codes. In Proceedings of the 2018 IEEE International Conference on Systems, Man, and Cybernetics (SMC), Miyazaki, Japan, 7–10 October 2018; pp. 3541–3546. [Google Scholar]
- Rahman, M.M.; Watanobe, Y.; Nakamura, K. Source Code Assessment and Classification Based on Estimated Error Probability Using Attentive LSTM Language Model and Its Application in Programming Education. Appl. Sci. 2020, 10, 2973. [Google Scholar] [CrossRef]
- Terada, K.; Watanobe, Y. Code Completion for Programming Education based on Recurrent Neural Network. In Proceedings of the 2019 IEEE 11th International Workshop on Computational Intelligence and Applications (IWCIA), Hiroshima, Japan, 9–10 November 2019; pp. 109–114. [Google Scholar]
- Rahman, M.M.; Watanobe, Y.; Nakamura, K. Evaluation of Source Codes Using Bidirectional LSTM Neural Network. In Proceedings of the 2020 3rd IEEE International Conference on Knowledge Innovation and Invention (ICKII), Kaohsiung, Taiwan, 21–23 August 2020; pp. 140–143. [Google Scholar]
- Le, P.; Zuidema, W.H. Quantifying the vanishing gradient and long distance dependency problem in recursive neural networks and recursive LSTMs. In Proceedings of the 1st Workshop on Representation Learning for NLP, Berlin, Germany, 11 August 2016; pp. 87–93. [Google Scholar]
- Schuster, M.; Paliwal, K.K. Bidirectional recurrent neural networks. IEEE Trans. Signal Process. 1997, 45, 2673–2681. [Google Scholar] [CrossRef] [Green Version]
- Intelligent Coding Environment (ICE). Available online: https://onlinejudge.u-aizu.ac.jp/services/ice/ (accessed on 11 December 2020).
- Song, D.; Lee, M.; Oh, H. Automatic and Scalable Detection of Logical Errors in Functional Programming Assignments. In Proceedings of the ACM Programming Languages OOPSLA, Athens, Greece, 20–25 October 2019; Volume 3. [Google Scholar]
- Allamanis, M.; Barr, E.T.; Devanbu, P.; Sutton, C. A Survey of Machine Learning for Big Code and Naturalness. ACM Comput. Surv. 2018, 51, 37. [Google Scholar] [CrossRef] [Green Version]
- Allamanis, M.; Barr, E.T.; Bird, C.; Sutton, C. Suggesting accurate method and class names. In Proceedings of the 2015 10th Joint Meeting on Foundations of Software Engineering (ESEC/FSE 2015). Association for Computing Machinery, Bergamo, Italy, 30 August–4 September 2015; pp. 38–49. [Google Scholar] [CrossRef] [Green Version]
- Wang, S.; Liu, T.; Tan, L. Automatically learning semantic features for defect prediction. In Proceedings of the 38th International Conference on Software Engineering (ICSE’16), Austin, TX, USA, 14–22 May 2016; pp. 297–308. [Google Scholar] [CrossRef]
- Pradel, M.; Sen, K. DeepBugs: A learning approach to name-based bug detection. In Proceedings of the ACM Programming Languages, Boston, MA, USA, 4–9 November 2018; Volume 2, pp. 1–147. [Google Scholar] [CrossRef] [Green Version]
- Song, X.; Chen, C.; Cui, B.; Fu, J. Malicious JavaScript Detection Based on Bidirectional LSTM Model. Appl. Sci. 2020, 10, 3440. [Google Scholar] [CrossRef]
- Graves, A.; Schmidhuber, J. Framewise phoneme classification with bidirectional LSTM and other neural network architectures. Neural Netw. 2005, 18, 602–610. [Google Scholar] [CrossRef] [PubMed]
- Aizu Online Judge. Developers Site (API). 2004. Available online: http://developers.u-aizu.ac.jp/index (accessed on 25 June 2020).
- Srivastava, N.; Hinton, G.; Krizhevsky, A.; Sutskever, I.; Salakhutdinov, R. Dropout: A simple way to prevent neural networks from overfitting. J. Mach. Learn. Res. 2014, 15, 1929–1958. [Google Scholar]
- Kingma, D.P.; Ba, J. Adam: A method for stochastic optimization. In Proceedings of the 3rd International Conference for Learning Representations (ICLR), San Diego, CA, USA, 7–9 May 2015; pp. 1–13. [Google Scholar]
Name of the Words | IDs |
---|---|
A–Z | 96–121 |
A–z | 127–152 |
!, ?,_, “, #, $, %, &, ‘, (,), *, +, -, ., / | 63–79 |
:, ;, <, =, >, @ | 90–95 |
[, \, ], ^ | 122–125 |
{, |, }, ~ | 153–156 |
Keywords of C programming language | 30–61 |
Functions | 0–29 |
SL | Hidden Units (Neurons) | LSTM | BiLSTM | ||
---|---|---|---|---|---|
GCD | IS | GCD | IS | ||
1 | 100 | 1.89 | 1.75 | 1.35 | 1.24 |
2 | 200 | 1.72 | 1.35 | 1.24 | 1.07 |
3 | 300 | 1.62 | 1.24 | 1.25 | 1.05 |
4 | 400 | 1.66 | 1.20 | 1.25 | 1.04 |
Location in Code | LSTM | BiLSTM | ||
---|---|---|---|---|
Detected | Suggested | Detected | Suggested | |
13 | = | ! | = | ! |
14 | n, m | m, n | ||
15 | m, n | n, m | ||
16 | l | l; | l | l; |
18 | printf | } |
Location in Code | LSTM | BiLSTM | ||
---|---|---|---|---|
Detected | Suggested | Detected | Suggested | |
3 | main | int main | ||
6 | = | < | <= n | < n |
16 | < | > | < key | > key |
17 | i | j | a[i] | a[j] |
18 | +,+ | -,- | j++ | j-- |
Publisher’s Note: MDPI stays neutral with regard to jurisdictional claims in published maps and institutional affiliations. |
© 2021 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (http://creativecommons.org/licenses/by/4.0/).
Share and Cite
Rahman, M.M.; Watanobe, Y.; Nakamura, K. A Bidirectional LSTM Language Model for Code Evaluation and Repair. Symmetry 2021, 13, 247. https://doi.org/10.3390/sym13020247
Rahman MM, Watanobe Y, Nakamura K. A Bidirectional LSTM Language Model for Code Evaluation and Repair. Symmetry. 2021; 13(2):247. https://doi.org/10.3390/sym13020247
Chicago/Turabian StyleRahman, Md. Mostafizer, Yutaka Watanobe, and Keita Nakamura. 2021. "A Bidirectional LSTM Language Model for Code Evaluation and Repair" Symmetry 13, no. 2: 247. https://doi.org/10.3390/sym13020247
APA StyleRahman, M. M., Watanobe, Y., & Nakamura, K. (2021). A Bidirectional LSTM Language Model for Code Evaluation and Repair. Symmetry, 13(2), 247. https://doi.org/10.3390/sym13020247