Affiliation:
1. Fudan University
2. CSIRO’s Data61 & Australian National University
Abstract
When searching code, developers may express additional constraints (e.g., functional constraints and nonfunctional constraints) on the implementations of desired functionalities in the queries. Existing code search tools treat the queries as a whole and ignore the different implications of different parts of the queries. Moreover, these tools usually return a ranked list of candidate code snippets without any explanations. Therefore, the developers often find it hard to choose the desired results and build confidence on them. In this article, we conduct a developer survey to better understand and address these issues and induct some insights from the survey results. Based on the insights, we propose XCoS, an explainable code search approach based on query scoping and knowledge graph. XCoS extracts a background knowledge graph from general knowledge bases like Wikidata and Wikipedia. Given a code search query, XCoS identifies different parts (i.e., functionalities, functional constraints, nonfunctional constraints) from it and use the expressions of functionalities and functional constraints to search the codebase. It then links both the query and the candidate code snippets to the concepts in the background knowledge graph and generates explanations based on the association paths between these two parts of concepts together with relevant descriptions. XCoS uses an interactive user interface that allows the user to better understand the associations between candidate code snippets and the query from different aspects and choose the desired results. Our evaluation shows that the quality of the extracted background knowledge and the concept linkings in codebase is generally high. Furthermore, the generated explanations are considered complete, concise, and readable, and the approach can help developers find the desired code snippets more accurately and confidently.
Funder
National Natural Science Foundation of China
Publisher
Association for Computing Machinery (ACM)
Reference84 articles.
1. Internet Archive. 2021. Stack Overflow Data Dump Version from March 4 2021. Retrieved September 4 2021 from https://archive.org/download/stackexchange/.
2. Wikimedia. 2021. Wikidata Data Dump Version from November 24 2021. Retrieved November 24 2021 from https://dumps.wikimedia.org/wikidatawiki/entities/.
3. Wikimedia. 2021. Wikipedia Data Dump Version from December 20 2021. Retrieved December 20 2021 from https://dumps.wikimedia.org/enwiki/.
4. Elastic Stack. 2022. Elasticsearch. Retrieved March 5 2022 from https://www.elastic.co/elasticsearch/.
5. GitHub. 2022. Javalang. Retrieved March 5 2022 from https://github.com/c2nes/javalang.
Cited by
7 articles.
订阅此论文施引文献
订阅此论文施引文献,注册后可以免费订阅5篇论文的施引文献,订阅后可以查看论文全部施引文献
1. A Survey of Source Code Search: A 3-Dimensional Perspective;ACM Transactions on Software Engineering and Methodology;2024-06-28
2. Mining Resource-Operation Knowledge to Support Resource Leak Detection;Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering;2023-11-30
3. Recommending Analogical APIs via Knowledge Graph Embedding;Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering;2023-11-30
4. KG4CraSolver: Recommending Crash Solutions via Knowledge Graph;Proceedings of the 31st ACM Joint European Software Engineering Conference and Symposium on the Foundations of Software Engineering;2023-11-30
5. Knowledge Graph based Explainable Question Retrieval for Programming Tasks;2023 IEEE International Conference on Software Maintenance and Evolution (ICSME);2023-10-01