Skip to main content
Log in

Code recommendation based on joint embedded attention network

  • Data analytics and machine learning
  • Published:
Soft Computing Aims and scope Submit manuscript

Abstract

Due to the heterogeneity of program language and natural language query, it is difficult to identify the semantic relationship between them, which leads to the low efficiency of code recommendation. In order to solve the problems of the above code recommendation technology, a code recommendation method based on joint embedded attention network (JEAN) is proposed in this paper. The method uses GRU Network to embed code snippets and describe queries into vector representation, which solves the problem of heterogeneous code snippets and natural language queries. The Attention mechanism is then used to distribute totally different weights to different components of every mode of the code snippet. The reason for the Attention mechanism is that different components of every mode of the code snippet contribute differently to the semantic vector of the final code snippet, making it interpretable. Finally, two commonly used evaluation indexes of information retrieval, SuccessRate@k and MRR, are used for experimental comparison with other baseline models. The experimental results show that the code recommendation method based on joint embedded attention network proposed in this paper can effectively recommend appropriate code snippets according to the needs of developers, and its performance is better than other baseline methods.

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Fig. 1
Fig. 2
Fig. 3
Fig. 4
Fig. 5
Fig. 6
Fig. 7
Fig. 8
Fig. 9
Fig. 10

Similar content being viewed by others

Data availability

The datasets analyzed during the current study are not publicly available.

References

  • Chatterjee S, Juvekar S, Sen K (2009) SNIFF: a search engine for Java using free-form queries. In: International conference on fundamental approaches to software engineering, pp 385–400

  • Collobert R, Weston J, Bottou L, Karlen M, Kavukcuoglu K, Kuksa P (2011) Natural language processing (almost) from scratch. J Mach Learn Res 12(Aug):2493–2537

    MATH  Google Scholar 

  • Dong L, Lapata M (2018) Coarse-to-fine decoding for neural semantic parsing. In: Proceedings of the 56th annual meeting of the association for computational linguistics (volume 1: long papers), pp 731–742

  • Frome A, Corrado GS, Shlens J, Bengio S, Dean J, Mikolov T et al (2013) DeViSE: a deep visual-semantic embedding model. In: Advances in neural information processing systems, pp 2121–2129

  • Gu X, Zhang H, Zhang D, Kim S (2016) Deep API learning. In: Proceedings of the ACM SIGSOFT 20th international symposium on the foundations of software engineering (FSE’16), pp 631–642

  • Gu X, Zhang H, Kim S (2018) Deep code search. In: 2018 IEEE/ACM 40th International conference on software engineering (ICSE). IEEE, pp 933–944

  • Hayati SA, Olivier R, Avvaru P, Yin P, Tomasic A, Neubig G (2018) Retrieval-based neural code generation. In: Proceedings of the 2018 conference on empirical methods in natural language processing, pp 925–930

  • Keivanloo I, Rilling J, Zou Y (2014) Spotting working code examples. In: Proceedings of the 36th international conference on software engineering. ACM, pp 664–675

  • Kim S, Zhao J, Tian Y, Chandra S (2021) Code prediction by feeding trees to transformers. In: Proceedings of 2021 IEEE/ACM 43rd international conference on software engineering (ICSE). IEEE, pp 150–162

  • Lam AN, Nguyen AT, Nguyen HA, Nguyen TN (2015) Combining deep learning with information retrieval to localize buggy files for bug reports (n). In: 2015 30th IEEE/ACM International conference on automated software engineering (ASE). IEEE, pp 476–481

  • Lawrence P, Brin S (1999) The pagerank citation ranking: bringing order to the web [R]. Stanford InfoLab, pp 1–14

  • Li X, Wang Z, Wang Q, Yan S, Xie T, Mei H (2016) Relationship-aware code search for JavaScript frameworks. In: Proceedings of the ACM SIGSOFT 24th international symposium on the foundations of software engineering, ACM

  • Ling W, Blunsom P, Grefenstette E, Hermann KM, Kočiský T, Wang F, Senior AW (2016) Latent predictor networks for code generation. In: Proceedings of the 54th annual meeting of the association for computational linguistics (ACL), pp 599–609

  • Linstead E, Bajracharya S, Ngo T, Rigor P, Lopes C, Baldi P (2009) Sourcerer: mining and searching internet-scale software repositories. Data Min Knowl Disc 18:300–336

    Article  MathSciNet  Google Scholar 

  • Lu M, Sun X, Wang S, Lo D, Duan Y (2015) Query expansion via wordnet for effective code search. In: 2015 IEEE 22nd International conference on software analysis, evolution, and reengineering (SANER). IEEE, pp 545–549

  • Lv F, Zhang H, Lou J, Wang S, Zhang D, Zhao J (2015) CodeHow: effective code search based on API understanding and extended boolean model. In: Proceedings of the 30th IEEE/ACM international conference on automated software engineering (ASE 2015). IEEE

  • Manning CD, Raghavan P, Schütze H (2008) Introduction to information retrieval. Cambridge University Press, Cambridge

    Book  Google Scholar 

  • McMillan C, Grechanik M, Poshyvanyk D, Xie Q, Fu C (2011) Portfolio: finding relevant functions and their usage. In: Proceedings international conference on software engineering (ICSE’11). IEEE, pp 111–120

  • Nie L, Jiang H, Ren Z, Sun Z, Li X (2016) Query expansion based on crowd knowledge for code search. IEEE Trans Serv Comput 9(5):771–783

    Article  Google Scholar 

  • Rabinovich M, Stern M, Klein D (2017) Abstract syntax networks for code generation and semantic parsing. In: Proceedings of the 55th annual meeting of the association for computational linguistics (ACL), pp 1139–1149

  • Rahman MM, Roy CK, Lo D (2016) Rack: automatic api recommendation using crowdsourced knowledge. In: 2016 IEEE 23rd International conference on software analysis, evolution, and reengineering (SANER), vol 1. IEEE, pp 349–359

  • Saha RK, Lease M, Khurshid S, Perry DE (2013) Improving bug localization using structured information retrieval. In: 2013 IEEE/ACM 28th International conference on automated software engineering (ASE). IEEE, pp 345–355

  • Shepherd D, Damevski K, Ropski B et al (2012) Sando: an extensible local code search framework. In: Proceedings of the ACM SIGSOFT 20th international symposium on the foundations of software engineering, pp 1–2

  • Singer J, Lethbridge T, Vinson N, Anquetil N (2010) An examination of software engineering work practices. In: CASCON first decade high impact papers. IBM Corp., pp 174–188

  • Stehnii A (2018) Generation of code from text description with syntactic parsing and tree2tree model. Master’s thesis, Ukrainian Catholic University

  • Stolee KT (2012) Finding suitable programs: semantic search with incomplete and lightweight specifications. In: Proceedings of the 34th international conference on software engineering, pp 1571−1574

  • Sun Z, Zhu Q, Mou L, Xiong Y, Li G, Zhang L (2019) A grammarbased structural cnn decoder for code generation. In: Proceedings of the AAAI conference on artificial intelligence (AAAI 2019), vol 33, pp 7055–7062

  • Wen M, Wu R, Cheung S-C (2016) Locus: locating bugs from software changes. In: 2016 31st IEEE/ACM international conference on automated software engineering (ASE). IEEE, pp 262–273

  • Ye X, Bunescu R, Liu C (2014) Learning to rank relevant files for bug reports using domain knowledge. In: Proceedings of the 22nd ACM SIGSOFT international symposium on foundations of software engineering. ACM, pp 689–699

  • Yin P, Neubig G (2017) A syntactic neural model for general-purpose code generation. In: Proceedings of the 55th annual meeting of the association for computational linguistics (ACL), pp 440–450

  • Zanjani MB, Kagdi H, Bird C (2016) Automatically recommending peer reviewers in modern code review. IEEE Trans Softw Eng 42(6):530–543

    Article  Google Scholar 

Download references

Acknowledgements

This work was supported in part by the Nantong Science and Technology Research Project under Grant JC2021125, JCZ21087.

Funding

This work is supported by the Nantong Science and Technology Research Project (Grant Numbers JC2021125 and JCZ21087).

Author information

Authors and Affiliations

Authors

Contributions

All authors contributed to the study conception and design. Material preparation, data collection and analysis, coding were performed by SW. All authors read and approved the final manuscript.

Corresponding author

Correspondence to Wanzhi Wen.

Ethics declarations

Conflict of interest

The authors declare that they have no conflict of interest.

Additional information

Publisher's Note

Springer Nature remains neutral with regard to jurisdictional claims in published maps and institutional affiliations.

Rights and permissions

Reprints and permissions

About this article

Check for updates. Verify currency and authenticity via CrossMark

Cite this article

Wen, W., Zhao, T., Wang, S. et al. Code recommendation based on joint embedded attention network. Soft Comput 26, 8635–8645 (2022). https://doi.org/10.1007/s00500-022-07244-z

Download citation

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s00500-022-07244-z

Keywords

Navigation