Abstract
This paper is dedicated to extracting idioms from source code written in Python language. Programming language idiom is the fragment of code which often occur in different programs. In this research and idiom is represented as the part of program abstract syntax tree (AST). For idiom extracting the subtree computing techniques are used. Idiom extracting process is similar to numeric function optimization: starting with root node, on each step we add one node to the subtree and compute subtree efficiency metric. When metric stops to grow, we consider subtree obtained the idiom. As subtree efficiency metric different functions can be used. These functions can have subtree length or subtree frequency as an arguments.
This is a preview of subscription content, log in via an institution.
Buying options
Tax calculation will be finalised at checkout
Purchases are for personal use only
Learn about institutional subscriptionsNotes
- 1.
html5lib-python, https://github.com/html5lib/html5lib-python.
- 2.
django, https://github.com/django/django.
- 3.
References
Allamanis, M., Sutton, C.: Mining idioms from source code. In: FSE 2014 Proceedings of the 22nd ACM SIGSOFT International Symposium on Foundations of Software Engineering, Hong Kong, China, 16–21 November 2014, pp. 472–483 (2014)
Merchante, J., Robles, G.: From Python to Pythonic: Searching for Python idioms in GitHub (2017)
Svajlenko, J., Roy, C.K.: A Survey on the Evaluation of Clone Detection Performance and Benchmarking (2020)
Jiménez, A., Berzal, F., Cubero, J.-C.: Frequent tree pattern mining: a survey. Intell. Data Anal. 14(6), 603–622 (2010)
A Language-Parametric Modular Framework for Mining Idiomatic Code Patterns
Ésik, Z. (ed.): FCT 1993. LNCS, vol. 710. Springer, Heidelberg (1993). https://doi.org/10.1007/3-540-57163-9
Abstract Syntax Trees. https://docs.python.org/3/library/ast.html. Accessed 30 May 2020
Allamanis, M., Barr, E., Bird, C., Devanbu, P., Marron, M., Sutton, C.: Mining semantic loop idioms. IEEE Trans. Softw. Eng., 651–668 (2018). https://doi.org/10.1109/tse.2018.2832048
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2020 Springer Nature Switzerland AG
About this paper
Cite this paper
Orlov, D. (2020). Finding Idioms in Source Code Using Subtree Counting Techniques. In: Margaria, T., Steffen, B. (eds) Leveraging Applications of Formal Methods, Verification and Validation: Engineering Principles. ISoLA 2020. Lecture Notes in Computer Science(), vol 12477. Springer, Cham. https://doi.org/10.1007/978-3-030-61470-6_4
Download citation
DOI: https://doi.org/10.1007/978-3-030-61470-6_4
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-61469-0
Online ISBN: 978-3-030-61470-6
eBook Packages: Computer ScienceComputer Science (R0)