Skip to main content

Finding Idioms in Source Code Using Subtree Counting Techniques

  • Conference paper
  • First Online:

Part of the book series: Lecture Notes in Computer Science ((LNTCS,volume 12477))

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

Chapter
USD   29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD   39.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD   54.99
Price excludes VAT (USA)
  • Compact, lightweight edition
  • Dispatched in 3 to 5 business days
  • Free shipping worldwide - see info

Tax calculation will be finalised at checkout

Purchases are for personal use only

Learn about institutional subscriptions

Notes

  1. 1.

    html5lib-python, https://github.com/html5lib/html5lib-python.

  2. 2.

    django, https://github.com/django/django.

  3. 3.

    https://github.com/topics/python?o=desc&s=stars.

References

  1. 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)

    Google Scholar 

  2. Merchante, J., Robles, G.: From Python to Pythonic: Searching for Python idioms in GitHub (2017)

    Google Scholar 

  3. Svajlenko, J., Roy, C.K.: A Survey on the Evaluation of Clone Detection Performance and Benchmarking (2020)

    Google Scholar 

  4. Jiménez, A., Berzal, F., Cubero, J.-C.: Frequent tree pattern mining: a survey. Intell. Data Anal. 14(6), 603–622 (2010)

    Article  Google Scholar 

  5. A Language-Parametric Modular Framework for Mining Idiomatic Code Patterns

    Google Scholar 

  6. Ésik, Z. (ed.): FCT 1993. LNCS, vol. 710. Springer, Heidelberg (1993). https://doi.org/10.1007/3-540-57163-9

    Book  MATH  Google Scholar 

  7. Abstract Syntax Trees. https://docs.python.org/3/library/ast.html. Accessed 30 May 2020

  8. 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

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Dmitry Orlov .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2020 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

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)

Publish with us

Policies and ethics