Skip to main content

Code Representation Based on Hybrid Graph Modelling

  • Conference paper
  • First Online:
Neural Information Processing (ICONIP 2021)

Part of the book series: Communications in Computer and Information Science ((CCIS,volume 1516))

Included in the following conference series:

  • 2383 Accesses

Abstract

Several sequence- or abstract syntax tree (AST)-based models have been proposed for modelling lexical-level and syntactic-level information of source code. However, an effective method of learning code semantic information is still lacking. Thus, we propose a novel code representation method based on hybrid graph modelling, called HGCR. HGCR is a code information extraction model. Specifically, in HGCR, two novel graphs, the Structure Graph (SG) and the Execution Data Flow Graph (EDFG), are first extracted from AST to model the syntactic structural and semantic information of source code, respectively. Then, two improved graph neural networks are applied to learn the graphs to obtain an effective code representation. We demonstrate the effectiveness of our model on two common code understanding tasks: code classification and code clone detection. Empirically, our model outperforms state-of-the-art models.

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

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 99.00
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever
Softcover Book
USD 129.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

Institutional subscriptions

Notes

  1. 1.

    https://www.dgl.ai/.

  2. 2.

    https://github.com/eliben/pycparser.

  3. 3.

    https://github.com/c2nes/javalang.

References

  1. Allamanis, M., Peng, H., Sutton, C.: A convolutional attention network for extreme summarization of source code. In: ICML (2016)

    Google Scholar 

  2. Gu, W., et al.: CRaDLe: deep code retrieval based on semantic dependency learning. Neural Netw. 141, 385–394 (2021)

    Google Scholar 

  3. Hindle, A., Barr, E.T., Gabel, M., Su, Z., Devanbu, P.: On the naturalness of software. Commun. ACM 59, 122–131 (2016)

    Google Scholar 

  4. Hua, W., Sui, Y., Wan, Y., Liu, G., Xu, G.: FCCA: hybrid code representation for functional clone detection using attention networks. IEEE Trans. Reliabil. 70, 304–318 (2020)

    Google Scholar 

  5. Kingma, D.P., Ba, J.: Adam: A method for stochastic optimization. In: ICLR (2014)

    Google Scholar 

  6. Kipf, T.N., Welling, M.: Semi-supervised classification with graph convolutional networks. In: ICLR (2017)

    Google Scholar 

  7. Mehrotra, N., Agarwal, N., Gupta, P., Anand, S., Lo, D., Purandare, R.: Modeling functional similarity in source code with graph-based Siamese networks. arXiv preprint arXiv:2011.11228 (2020)

  8. Sun, Z., Zhu, Q., Xiong, Y., Sun, Y., Mou, L., Zhang, L.: TreeGen: a tree-based transformer architecture for code generation. In: AAAI (2020)

    Google Scholar 

  9. Tufano, M., Watson, C., Bavota, G., Di Penta, M., White, M., Poshyvanyk, D.: Deep learning similarities from different representations of source code. In: MSR (2018)

    Google Scholar 

  10. Vaswani, A., et al.: Attention is all you need. In: NeurIPS (2017)

    Google Scholar 

  11. Veličković, P., Cucurull, G., Casanova, A., Romero, A., Lio, P., Bengio, Y.: Graph attention networks. In: ICLR (2018)

    Google Scholar 

  12. Wang, W., Li, G., Ma, B., Xia, X., Jin, Z.: Detecting code clones with graph neural network and flow-augmented abstract syntax tree. In: SANER (2020)

    Google Scholar 

  13. Wang, Y., Li, H.: Code completion by modeling flattened abstract syntax trees as graphs. arXiv preprint arXiv:2103.09499 (2021)

Download references

Acknowledgement

This work is financially supported by the National Natural Science Foundation of China (61602286, 61976127) and the Special Project on Innovative Methods (2020IM020100).

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Chen Lyu .

Editor information

Editors and Affiliations

Rights and permissions

Reprints and permissions

Copyright information

© 2021 Springer Nature Switzerland AG

About this paper

Check for updates. Verify currency and authenticity via CrossMark

Cite this paper

Wu, Q., Jiang, X., Zheng, Z., Gao, X., Lyu, C., Lyu, L. (2021). Code Representation Based on Hybrid Graph Modelling. In: Mantoro, T., Lee, M., Ayu, M.A., Wong, K.W., Hidayanto, A.N. (eds) Neural Information Processing. ICONIP 2021. Communications in Computer and Information Science, vol 1516. Springer, Cham. https://doi.org/10.1007/978-3-030-92307-5_35

Download citation

  • DOI: https://doi.org/10.1007/978-3-030-92307-5_35

  • Published:

  • Publisher Name: Springer, Cham

  • Print ISBN: 978-3-030-92306-8

  • Online ISBN: 978-3-030-92307-5

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics