{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,10,2]],"date-time":"2026-10-02T10:26:53Z","timestamp":1790936813151,"version":"4.1.0"},"reference-count":31,"publisher":"Association for Computing Machinery (ACM)","issue":"FSE","license":[{"start":{"date-parts":[[2025,6,19]],"date-time":"2025-06-19T00:00:00Z","timestamp":1750291200000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/legalcode"}],"funder":[{"DOI":"10.13039\/501100001809","name":"National Natural Science Foundation of China","doi-asserted-by":"publisher","award":["62302536, 62032025"],"award-info":[{"award-number":["62302536, 62032025"]}],"id":[{"id":"10.13039\/501100001809","id-type":"DOI","asserted-by":"publisher"}]},{"DOI":"10.13039\/501100021171","name":"Guangdong Basic and Applied Basic Research Foundation","doi-asserted-by":"crossref","award":["2023A1515012292"],"award-info":[{"award-number":["2023A1515012292"]}],"id":[{"id":"10.13039\/501100021171","id-type":"DOI","asserted-by":"crossref"}]}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Proc. ACM Softw. Eng."],"published-print":{"date-parts":[[2025,6,19]]},"abstract":"<jats:p>Code snippets are widely used in technical forums to demonstrate solutions to programming problems. They can be leveraged by developers to accelerate problem-solving. However, code snippets often lack concrete types of the APIs used in them, which impedes their understanding and resue. To enhance the description of a code snippet, a number of approaches are proposed to infer the types of APIs. Although existing approaches can achieve good performance, their performance is limited by ignoring other information outside the input code snippet (e.g., the descriptions of similar code snippets) that could potentially improve the performance.<\/jats:p>\n                  <jats:p>In this paper, we propose a novel type inference approach, named CKTyper, by leveraging crowdsourcing knowledge in technical posts. The key idea is to generate a relevant context for a target code snippet from the posts containing similar code snippets and then employ the context to promote the type inference with large language models (e.g., ChatGPT). More specifically, we build a crowdsourcing knowledge base (CKB) by extracting code snippets from a large set of posts and index the CKB using Lucene. An API type dictionary is also built from a set of API libraries. Given a code snippet to be inferred, we first retrieve a list of similar code snippets from the indexed CKB. Then, we generate a crowdsourcing knowledge context (CKC) by extracting and summarizing useful content (e.g., API-related sentences) in the posts that contain the similar code snippets. The CKC is subsequently used to improve the type inference of ChatGPT on the input code snippet. The hallucination of ChatGPT is eliminated by employing the API type dictionary. Evaluation results on two open-source datasets demonstrate the effectiveness and efficiency of CKTyper. CKTyper achieves the optimal precision\/recall of 97.80% and 95.54% on both datasets, respectively, significantly outperforming three state-of-the-art baselines and ChatGPT.<\/jats:p>","DOI":"10.1145\/3715724","type":"journal-article","created":{"date-parts":[[2025,6,19]],"date-time":"2025-06-19T11:16:02Z","timestamp":1750331762000},"page":"176-196","source":"Crossref","is-referenced-by-count":2,"title":["CKTyper: Enhancing Type Inference for Java Code Snippets by Leveraging Crowdsourcing Knowledge in Stack Overflow"],"prefix":"10.1145","volume":"2","author":[{"ORCID":"https:\/\/orcid.org\/0009-0001-4881-4148","authenticated-orcid":false,"given":"Anji","family":"Li","sequence":"first","affiliation":[{"name":"Sun Yat-sen University, Zhuhai, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0001-8662-5690","authenticated-orcid":false,"given":"Neng","family":"Zhang","sequence":"additional","affiliation":[{"name":"Central China Normal University, Wuhan, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-5335-0261","authenticated-orcid":false,"given":"Ying","family":"Zou","sequence":"additional","affiliation":[{"name":"Queen's University, Kingston, Canada"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0009-0002-6536-5978","authenticated-orcid":false,"given":"Zhixiang","family":"Chen","sequence":"additional","affiliation":[{"name":"Sun Yat-sen University, Zhuhai, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-1559-9314","authenticated-orcid":false,"given":"Jian","family":"Wang","sequence":"additional","affiliation":[{"name":"Wuhan University, Wuhan, China"}],"role":[{"vocabulary":"crossref","role":"author"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-7878-4330","authenticated-orcid":false,"given":"Zibin","family":"Zheng","sequence":"additional","affiliation":[{"name":"Sun Yat-sen University, Zhuhai, China"}],"role":[{"vocabulary":"crossref","role":"author"}]}],"member":"320","published-online":{"date-parts":[[2025,6,19]]},"reference":[{"key":"e_1_3_1_2_2","doi-asserted-by":"publisher","DOI":"10.1109\/RSSE.2012.6233404"},{"key":"e_1_3_1_3_2","doi-asserted-by":"publisher","DOI":"10.1007\/s10664-012-9231-y"},{"key":"e_1_3_1_4_2","unstructured":"Zhixiang Chen Anji Li Neng Zhang Jianguo Chen Yuan Huang and Zibin Zheng. 2024. iJTyper: An Iterative Type Inference Framework for Java by Integrating Constraint- and Statistically-based Methods. arXiv:2402.09995 [cs.SE] https:\/\/arxiv.org\/abs\/2402.09995"},{"key":"e_1_3_1_5_2","doi-asserted-by":"publisher","DOI":"10.1017\/S1351324916000334"},{"key":"e_1_3_1_6_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2012.6227207"},{"key":"e_1_3_1_7_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-540-78800-3_24"},{"key":"e_1_3_1_8_2","doi-asserted-by":"publisher","unstructured":"Yiwen Dong Tianxiao Gu Yongqiang Tian and Chengnian Sun. 2022. SnR: constraint-based type inference for incomplete Java code snippets. In Proceedings of the 44th International Conference on Software Engineering. 1982\u20131993. doi:10.1145\/3510003.3510061","DOI":"10.1145\/3510003.3510061"},{"key":"e_1_3_1_9_2","doi-asserted-by":"publisher","unstructured":"Aryaz Eghbali and Michael Pradel. 2022. CrystalBLEU: precisely and efficiently measuring the similarity of code. In Proceedings of the 37th IEEE\/ACM International Conference on Automated Software Engineering. 1\u201312. doi:10.1145\/3551349.3556903","DOI":"10.1145\/3551349.3556903"},{"key":"e_1_3_1_10_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-3-319-96142-2_2"},{"key":"e_1_3_1_11_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSME.2018.00031"},{"key":"e_1_3_1_12_2","doi-asserted-by":"publisher","unstructured":"Qing Huang Zhiqiang Yuan Zhenchang Xing Xiwei Xu Liming Zhu and Qinghua Lu. 2022. Prompt-tuned code language model as a neural knowledge base for type inference in statically-typed partial code. In Proceedings of the 37th IEEE\/ACM International Conference on Automated Software Engineering. 1\u201313. doi:10.1145\/3551349.3556912","DOI":"10.1145\/3551349.3556912"},{"key":"e_1_3_1_13_2","doi-asserted-by":"publisher","DOI":"10.1145\/3428193"},{"key":"e_1_3_1_14_2","doi-asserted-by":"publisher","DOI":"10.1109\/ICSE.2019.00045"},{"key":"e_1_3_1_15_2","doi-asserted-by":"publisher","DOI":"10.3115\/1073083.1073135"},{"key":"e_1_3_1_16_2","doi-asserted-by":"publisher","unstructured":"Yun Peng Cuiyun Gao Zongjie Li Bowei Gao David Lo Qirun Zhang and Michael Lyu. 2022. Static inference meets deep learning: a hybrid type inference approach for Python. In Proceedings of the 44th International Conference on Software Engineering. 2019\u20132030. doi:10.1145\/3510003.3510038","DOI":"10.1145\/3510003.3510038"},{"key":"e_1_3_1_17_2","doi-asserted-by":"publisher","DOI":"10.1109\/ASE56229.2023.00031"},{"key":"e_1_3_1_18_2","doi-asserted-by":"publisher","unstructured":"Hung Phan Hoan Anh Nguyen Ngoc M Tran Linh H Truong Anh Tuan Nguyen and Tien N Nguyen. 2018. Statistical learning of api fully qualified names in code snippets of online forums. In Proceedings of the 40th International Conference on Software Engineering. 632\u2013642. doi:10.1145\/3180155.3180230","DOI":"10.1145\/3180155.3180230"},{"key":"e_1_3_1_19_2","doi-asserted-by":"publisher","unstructured":"Stephen Robertson Hugo Zaragoza and Michael Taylor. 2004. Simple BM25 extension to multiple weighted fields. In Proceedings of the thirteenth ACM international conference on Information and knowledge management. 42\u201349. doi:10.1145\/1031171.1031181","DOI":"10.1145\/1031171.1031181"},{"key":"e_1_3_1_20_2","doi-asserted-by":"publisher","DOI":"10.1007\/s10664-015-9379-3"},{"key":"e_1_3_1_21_2","doi-asserted-by":"publisher","unstructured":"Caitlin Sadowski Kathryn T Stolee and Sebastian Elbaum. 2015. How developers search for code: a case study. In Proceedings of the 2015 10th joint meeting on foundations of software engineering. 191\u2013201. doi:10.1145\/2786805.2786855","DOI":"10.1145\/2786805.2786855"},{"key":"e_1_3_1_22_2","doi-asserted-by":"publisher","DOI":"10.1145\/2901739.2901767"},{"key":"e_1_3_1_23_2","doi-asserted-by":"publisher","DOI":"10.1145\/3428193"},{"key":"e_1_3_1_24_2","unstructured":"Ali Shokri and Mehdi Mirakhorli. 2021. Depres: A tool for resolving fully qualified names and their dependencies. arXiv preprint arXiv:2108.01165 abs\/2108.01165 (2021). arXiv:2108.01165 https:\/\/arxiv.org\/abs\/2108.01165"},{"key":"e_1_3_1_25_2","doi-asserted-by":"publisher","unstructured":"Siddharth Subramanian Laura Inozemtseva and Reid Holmes. 2014. Live API documentation. In Proceedings of the 36th international conference on software engineering. 643\u2013652. doi:10.1145\/2568225.2568313","DOI":"10.1145\/2568225.2568313"},{"key":"e_1_3_1_26_2","doi-asserted-by":"publisher","unstructured":"Valerio Terragni Yepang Liu and Shing-Chi Cheung. 2016. CSNIPPEX: automated synthesis of compilable code snippets from Q&A sites. In Proceedings of the 25th international symposium on software testing and analysis. 118\u2013129. doi:10.1145\/2931037.2931058","DOI":"10.1145\/2931037.2931058"},{"key":"e_1_3_1_27_2","doi-asserted-by":"publisher","DOI":"10.1016\/j.scico.2023.102941"},{"key":"e_1_3_1_28_2","volume-title":"8th International Conference on Learning Representations, ICLR 2020","author":"Wei Jiayi","year":"2020","unstructured":"Jiayi Wei, Maruth Goyal, Greg Durrett, and Isil Dillig. 2020. LambdaNet: Probabilistic Type Inference using Graph Neural Networks. In 8th International Conference on Learning Representations, ICLR 2020. OpenReview.net. https:\/\/openreview.net\/forum?id=Hkx6hANtwH"},{"key":"e_1_3_1_29_2","doi-asserted-by":"publisher","DOI":"10.1007\/978-1-4612-4380-9_16"},{"key":"e_1_3_1_30_2","doi-asserted-by":"publisher","DOI":"10.1145\/2901739.2901767"},{"key":"e_1_3_1_31_2","doi-asserted-by":"publisher","DOI":"10.1109\/SANER.2016.10"},{"key":"e_1_3_1_32_2","first-page":"11328","volume-title":"International conference on machine learning","author":"Zhang Jingqing","year":"2020","unstructured":"Jingqing Zhang, Yao Zhao, Mohammad Saleh, and Peter Liu. 2020. Pegasus: Pre-training with extracted gap-sentences for abstractive summarization. In International conference on machine learning (Proceedings of Machine Learning Research, Vol. 119). PMLR, 11328\u201311339. http:\/\/proceedings.mlr.press\/v119\/zhang20ae.html"}],"container-title":["Proceedings of the ACM on Software Engineering"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/dl.acm.org\/doi\/pdf\/10.1145\/3715724","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2026,8,23]],"date-time":"2026-08-23T11:07:21Z","timestamp":1787483241000},"score":1,"resource":{"primary":{"URL":"https:\/\/dl.acm.org\/doi\/10.1145\/3715724"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2025,6,19]]},"references-count":31,"journal-issue":{"issue":"FSE","published-print":{"date-parts":[[2025,6,19]]}},"alternative-id":["10.1145\/3715724"],"URL":"https:\/\/doi.org\/10.1145\/3715724","relation":{},"ISSN":["2994-970X"],"issn-type":[{"value":"2994-970X","type":"electronic"}],"subject":[],"published":{"date-parts":[[2025,6,19]]}}}