A Recommendation System for Finding Semantically Similar Fragments of Program Code

Main Article Content

Vitaly Ivanovich Zorin
Evgeny Konstantinovich Lipachev

Abstract

Recommendation systems in the scientific information space serve as essential tools for search and navigation when working with scientific documents. Software code is currently considered as an object of scientific knowledge and, as a result, an important task is to create software lifecycle support systems, in particular, to find similar software solutions, detect code borrowings, analyze and evaluate code quality.


This paper proposes a content-based recommender system that provides users with a personalized list of code fragments that are functionally equivalent to the input query code presented in one of the programming languages from the established set.


The basic algorithm of the system is based on the representation of the program code in the form of an abstract syntax tree followed by the construction of a vector space of program codes. The semantic similarity of program codes is determined by the distance between code vectors in a multidimensional space.


The personalization of recommendations is achieved through a filtering module that ranks the retrieved fragments taking into account the user's profile. The factors under consideration are the language preferences of the user and his areas of scientific interests, extracted through integration with ORCID.


To ensure the system's operation, a specialized dataset was created based on the CodeNet corpus. The problem of automated language detection from a snippet of the presented code in one of the 19 languages included in the current rating list of programming languages has also been solved.

Article Details

How to Cite
Zorin, V. I., and E. K. Lipachev. “A Recommendation System for Finding Semantically Similar Fragments of Program Code”. Russian Digital Libraries Journal, vol. 29, no. 3, June 2026, pp. 751-8, doi:10.26907/1562-5419-2026-29-3-751-781.

References

1. Yang H., Nong Y., Wang S., Cai H. Multi-Language Software Development: Issues, Challenges, and Solutions // IEEE Transactions on Software Engineering. 2024. Vol. 50, No. 3. P. 512–533. https://doi.org/10.1109/TSE.2024.3358258
2. Vislavski T., Rakić G., Cardozo N., Budimac Z. LICCA: A tool for cross-language clone detection // 2018 IEEE 25th International Conference on Software Analysis, Evolution and Reengineering (SANER), Campobasso, Italy, 2018. P. 512–516. https://doi.org/10.1109/SANER.2018.8330250
3. Nafi K.W., Kar T.S., Roy B., Roy C.K., Schneider K.A. CLCDSA: Cross Language Code Clone Detection using Syntactical Features and API Documentation // 2019 34th IEEE/ACM International Conference on Automated Software Engineering (ASE), San Diego, USA, 2019. P. 1026–1037. https://doi.org/10.1109/ASE.2019.00099
4. Mathew G., Stolee K.T. Cross-language code search using static and dynamic analyses // Proceedings of the 29th ACM Joint Meeting on European Software Engineering Conference and Symposium on the Foundations of Software Engineering, New York, USA, 2021. P. 205–217. https://doi.org/10.1145/3468264.3468538
5. Tao C., Zhan Q., Hu X., Xia X. C4: contrastive cross-language code clone detection // ICPC '22: Proceedings of the 30th IEEE/ACM International Conference on Program Comprehension, New York, USA, 2022. P. 413–424. https://doi.org/10.1145/3524610.3527911
6. Saieva A., Chakraborty S., Kaiser G. Reinforest: Reinforcing Semantic Code Similarity for Cross-Lingual Code Search Models // 2024 IEEE International Conference on Source Code Analysis and Manipulation (SCAM). 2023. P. 177–188. https://doi.org/10.1109/SCAM63643.2024.00026
7. Ricci F., Rokach L., Shapira B. (Eds.) Recommender Systems Handbook. Springer New York, N.Y., 2022. 1060 p. https://doi.org/10.1007/978-1-0716-2197-4
8. de Gemmis M., Lops P., Musto C., Narducci F., Semeraro G. Semantics-Aware Content-Based Recommender Systems // In: Ricci F., Rokach L., Shapira B. (Eds.) Recommender Systems Handbook. Springer, Boston, MA, 2015. P. 119–159. https://doi.org/10.1007/978-1-4899-7637-6_4
9. Falk K. Recommender Systems in Practice: A Practical Guide. Springer, Berlin, 2016. 340 p.
10. Manouselis N., Drachsler H., Verbert K., Duval E. Recommender Systems for Learning. Springer, 2013. https://doi.org/10.1007/978-1-4614-4361-2
11. Elizarov A.M., Lipachev E.K., Zhizhchenko A.B., Zhil’tsov N.G., Kirillovich A.V. Mathematical Knowledge Ontologies and Recommender Systems for Collections of Documents in Physics and Mathematics // Doklady Mathematics. 2016. Vol. 93, No. 2. P. 231–233. https://doi.org/10.1134/S1064562416020174
12. Elizarov A.M., Lipachev E.K., Khaydarov S.M. Method of automated selection of reviewers of scientific articles, implemented in the scientific journal information system // Nauchny`j servis v seti Internet. M: IPM im. Keldysha, 2019. P. 318–328. https://doi.org/10.20948/abrau-2019-94
13. Elizarov A.M., Lipachev E.K., Khaydarov S.M. Recommender system in the process of scientific peer review in mathematical journal // Russian Digital Libraries Journal. 2020. Vol. 23, No. 4. P. 708–732. https://doi.org/10.26907/1562-5419-2020-23-4-708-732
14. Smyth B. Case-based recommendation // In: Brusilovsky A., Kobsa W. (Eds). The Adaptive Web: Methods and Strategies of Web Personalization, Lecture Notes in Computer Science, Springer, Berlin, 2007. P. 342–376.
15. Ataeva O.M., Tuchkova N.P., Degtev A.G. Recommendation system based on a generalized journal index // Ontology of Designing. 2025. Vol. 15, No. 4. P. 598–613. https://doi.org/10.18287/2223-9537-2025-15-4-598-613
16. The MaRDI consortium. MaRDI: Mathematical Research Data Initiative Proposal. 2022. https://doi.org/10.5281/zenodo.6552436
17. Kalinin N.A., Skvortsov N.A. Difficulties of FAIR Principles Implementation in Cross-Domain Research Infrastructures // Lobachevskii J. Math. 2023. Vol. 44, No. 1. P. 147–156. https://doi.org/10.1134/S199508022301016X
18. Mathew. G, Parnin C., Stolee K.T. SLACC: simion-based language agnostic code clones // Proc. of the ACM/IEEE 42nd International Conference on Software Engineering. 2020. P. 210–221. https://doi.org/10.1145/3377811.3380407
19. Li J., Tao C., Jin Z., Liu F., Li J., Li G. ZC3: Zero-Shot Cross-Language Code Clone Detection // 2023 38th IEEE/ACM International Conference on Automated Software Engineering (ASE). 2023. P. 875–887. https://doi.org/10.1109/ASE56229.2023.00210
20. Hu M., Yang J., Zhou W. Cross-language code clone detection via flow-enhanced graph attention network // The Computer Journal. 2026. https://doi.org/10.1093/comjnl/bxaf146
21. Petrov V.V. Automated system for numerical similarity evaluation of android applications // Russian Digital Libraries Journal. 2024. Vol. 27, No. 3. P. 336–365. https://doi.org/10.26907/1562-5419-2024-27-3-336-365
22. Petrov V.V. Automated system for numerical similarity evaluation of android applications // Automatic documentation and mathematical linguistics. 2024. Vol. 58, No. 3. P. 131–142. https://doi.org/10.3103/S0005105525700207
23. Riesen K. Structural Pattern Recognition with Graph Edit Distance. Springer, Cham, 2015. 158 p. https://doi.org/10.1007/978-3-319-27252-8
24. The Top Programming Languages 2025. 2025. URL: https://spectrum.ieee.org/top-programming-languages-2025 (Accessed: 22.03.2026).
25. Top yazy`kov programmirovaniya v 2025 godu: rejting IEEE i vliyanie na nego yazy`kovy`x modelej // Habr-blog, 2025. URL: https://habr.com/ru/companies/selectel/articles/951348 (Accessed: 22.03.2026).
26. Zorin V.I., Lipachev E.K. A method for calculating the similarity measure of program code fragments // Highly Available Systems. 2026. Vol. 22, No. 1. P. 47−50. https://doi.org/10.18127/j20729472-202601-09
27. Euzenat J., Shvaiko P. Basic similarity measures // In: Ontology Matching. Springer, Berlin, Heidelberg, 2013. P. 85–120. https://doi.org/10.1007/978-3-642-38721-0_5
28. Puri R. et al. CodeNet: A Large-Scale AI for Code Dataset for Learning a Diversity of Coding Tasks // NeurIPS Datasets and Benchmarks. 2021. https://doi.org/10.48550/arXiv.2105.12655
29. Zorin V.I. Programming Language Detection Dataset (1.0.0). https://doi.org/10.5281/zenodo.15661548
30. Aho A.V., Lam M.S., Sethi R., Ullman J.D. Compilers: Principles, Techniques, and Tools (2 ed.). Addison-Wesley, Boston, 2006. 1006 p.
31. Gorodnyaya L.V. Forms for displaying the results of comparison of programming languages using the example of dialects of the LISP language // Russian Digital Libraries Journal. 2026. Vol. 29, No. 1. P. 24–59. https://doi.org/10.26907/1562-5419-2026-29-1-24-59
32. Feng Z., Guo D., Tang D., Duan N., Feng X., Gong M., Shou L., Qin B., Liu T., Jiang D., Zhou M. CodeBERT: A Pre-Trained Model for Programming and Natural Languages // Empirical Methods in Natural Language Processing. 2020. P. 1536–1547. https://doi.org/10.18653/v1/2020.findings-emnlp.139
33. Alon U., Zilberstein M., Levy O., Yahav E. code2vec: learning distributed representations of code // Proc. of the ACM on Programming Languages. 2019. Vol. 3, No. POPL. P. 1–29. https://doi.org/10.1145/3290353
34. Bui N.D.Q., Yu Y., Jiang L. InferCode: Self-Supervised Learning of Code Representations by Predicting Subtrees // 2021 IEEE/ACM 43rd International Conference on Software Engineering (ICSE). 2020. P. 1186–1197. https://doi.org/10.1109/ICSE43902.2021.00109
35. Guo D. et al. GraphCodeBERT: Pre-training Code Representations with Data Flow // arXiv:2009.08366. 2020. https://doi.org/10.48550/arXiv.2009.08366
36. Guo D., Lu S., Duan N., Wang Y., Zhou M., Yin J. UniXcoder: Unified Cross-Modal Pre-training for Code Representation // Proceedings of the 60th Annual Meeting of the Association for Computational Linguistics (Volume 1: Long Papers), Dublin, 2022. P. 7212–7225. https://doi.org/10.18653/v1/2022.acl-long.499
37. Musto C., Gemmis M.d., Lops P., Narducci F., Semeraro G. Semantics and Content-Based Recommendations // F. Ricci, L. Rokach, B. Shapira (Eds.) Recommender Systems Handbook. Springer New York, N.Y., 2022. P. 251–298. https://doi.org/10.1007/978-1-0716-2197-4_7
38. Svajlenko J., Roy C.K. BigCloneEval: A Clone Detection Tool Evaluation Framework with BigCloneBench // ICSME, 2016. P. 596–600. https://doi.org/10.1109/ICSME.2016.62
39. Elizarov A.M., Kirillovich A.V., Lipachev E.K., Nevzorova O.A. Digital Ecosystem OntoMath as an Approach to Building the Space of Mathematical Knowledge // Russian Digital Libraries Journal. 2023. Vol. 26, No. 2. P. 154–202.
https://doi.org/10.26907/1562-5419-2023-26-2-154-202


Most read articles by the same author(s)