计算机应用 ›› 2017, Vol. 37 ›› Issue (10): 2958-2963.DOI: 10.11772/j.issn.1001-9081.2017.10.2958
顾逸圣1,2, 曾国荪1
收稿日期:
2017-04-21
修回日期:
2017-06-09
发布日期:
2017-10-16
出版日期:
2017-10-10
通讯作者:
顾逸圣(1992-),男,上海人,硕士研究生,主要研究方向:软件工程、代码搜索,E-mail:qswy929@163.com
作者简介:
顾逸圣(1992-),男,上海人,硕士研究生,主要研究方向:软件工程、代码搜索;曾国荪(1964-),男,江西吉安人,教授,博士,博士生导师,主要研究方向:并行计算、可信软件、信息安全.
基金资助:
GU Yisheng1,2, ZENG Guosun1
Received:
2017-04-21
Revised:
2017-06-09
Online:
2017-10-16
Published:
2017-10-10
Supported by:
摘要: 针对在编写软件、复用源代码的过程中仅依靠关键词无法精准搜索到适用源代码的问题,提出一种将语法和语义结合的源代码精准搜索方法。首先依据源代码语法语义的客观和唯一性,增加语法结构和"输入/输出"语义作为用户录入请求的一部分,并规范了具体的请求格式;然后在此基础上分别设计源代码语法匹配算法、"输入/输出"语义匹配算法、关键词兼容匹配,以及源代码搜索结果可信度计算算法;最后综合上述算法实现对源代码的精准搜索。测试结果表明:与单纯的关键词搜索相比,提出的方法对搜索的平均排序倒数(MRR)有超过62%的提升,有助于实现源代码的精准搜索。
中图分类号:
顾逸圣, 曾国荪. 基于语法和语义结合的源代码精确搜索方法[J]. 计算机应用, 2017, 37(10): 2958-2963.
GU Yisheng, ZENG Guosun. Accurate search method for source code by combining syntactic and semantic queries[J]. Journal of Computer Applications, 2017, 37(10): 2958-2963.
[1] BAJRACHARYA S, NGO T, LINSTEAD E, et al. Sourcerer: a search engine for open source code supporting structure-based search [C]//OOPSLA 2006: Companion To the 21st ACM SIGPLAN Symposium on Object-Oriented Programming Systems, Languages, and Applications. New York: ACM, 2006: 681-682. [2] FARAH G, TEJADA J S, CORREAL D. OpenHub: a scalable architecture for the analysis of software quality attributes [C]//MSR 2014: Proceedings of the 11th Working Conference on Mining Software Repositories. New York: ACM, 2014: 420-423. [3] PAUL S, PRAKASH A. A framework for source code search using program patterns[J]. IEEE Transactions on Software Engineering, 1994, 20(6): 463-475. [4] HILL E, POLLOCK L, VIJAY-SHANKER K. Improving source code search with natural language phrasal representations of method signatures [C]//ASE 2011: Proceedings of the 2011 26th IEEE/ACM International Conference on Automated Software Engineering. Washington, DC: IEEE Computer Society, 2011: 524-527. [5] 胡翔, 舒礼莲. 基于语义网络的海量源代码搜索引擎[J]. 计算机与现代化, 2014, 30(7): 19-23. (HU X, SHU L L. Search engine of massive source code based on semantic network[J]. Computer and Modernization, 2014, 30(7): 19-23.) [6] 孟骁. 基于语义网络的智能搜索引擎研究[D]. 长春: 东北师范大学, 2011. (MENG X. Research of intelligent search engine based on semantic Web[D]. Changchun: Northeast Normal University, 2011.) [7] 刘石, 李合, 王啸吟, 等. 基于语法与语义分析的代码搜索结果优化[J]. 计算机科学, 2009, 32(8): 165-168. (LIU S, LI H, WANG X Y, et al. Enhancement of code search results using syntax and semantic analysis[J]. Computer Science, 2009, 32(8): 165-168.) [8] KEIVANLOO I, ROOSTAPOUR L, SCHUGERL P, et al. SE-CodeSearch: a scalable semantic Web-based source code search infrastructure [C]//ICSM 2010: Proceedings of the 2010 26th IEEE International Conference on Software Maintenance. Piscataway, NJ: IEEE, 2010: 1-5. [9] STOLEE K T, ELBAUM S, DOBOS D. Solving the search for source code[J]. ACM Transactions on Software Engineering and Methodology, 2014, 23(3): 26-26. [10] STOLEE K T, ELBAUM S, DWYER M B, et al. Code search with input/output queries: generalizing, ranking, and assessment[J]. Journal of Systems and Software, 2016, 116(6): 35-48. [11] 满海霞, 梁雅梦. 乔姆斯基层级与自然语言语法——从短语结构语法到非转换语法[J]. 外国语文, 2015, 31(3): 84-89. (MAN H X, LIANG Y M. Chomsky hierarchy and natural language grammars: from phrase structure grammar to non-transformational grammar[J]. Foreign Language and Literature, 2015, 31(3): 84-89.) [12] 陈火旺. 程序设计语言编译原理[M]. 北京: 国防工业出版社, 2000. (CHEN H W. Programming Language and Compile Principles[M]. Beijing: National Defense Industry Press, 2000.) [13] RAJESHWARKAR A, NAGORI M. Optimizing search results using Wikipedia based ESS and enhanced TF-IDF approach[J]. International Journal of Computer Applications, 2016, 144(12): 23-28. [14] FREITAS A, OLIVEIRA J G, ORIAIN S, et al. Querying linked data using semantic relatedness: a vocabulary independent approach [C]//NLDB 2011: Proceedings of the 16th International Conference on Application of Natural Language to Information Systems. Berlin: Springer, 2011: 40-51. |
[1] | 高威 刘丽华 和斌涛 邓方安. 区块链共识机制与改进算法研究进展[J]. 《计算机应用》唯一官方网站, 0, (): 0-0. |
[2] | 翟社平 朱鹏举 杨锐 刘佳一腾. 基于区块链的物联网身份管理系统[J]. 《计算机应用》唯一官方网站, 0, (): 0-0. |
[3] | 李博, 黄建强, 黄东强, 王晓英. 基于异构平台的稀疏矩阵向量乘自适应计算优化[J]. 《计算机应用》唯一官方网站, 2024, 44(12): 3867-3875. |
[4] | 陈姿芊, 牛科迪, 姚中原, 斯雪明. 适用于物联网的区块链轻量化技术综述[J]. 《计算机应用》唯一官方网站, 2024, 44(12): 3688-3698. |
[5] | 高婷婷, 姚中原, 贾淼, 斯雪明. 链上链下一致性保护技术综述[J]. 《计算机应用》唯一官方网站, 2024, 44(12): 3658-3668. |
[6] | 贾淼, 姚中原, 祝卫华, 高婷婷, 斯雪明, 邓翔. 零知识证明赋能区块链的进展与展望[J]. 《计算机应用》唯一官方网站, 2024, 44(12): 3669-3677. |
[7] | 牛科迪, 李敏, 姚中原, 斯雪明. 面向物联网的区块链共识算法综述[J]. 《计算机应用》唯一官方网站, 2024, 44(12): 3678-3687. |
[8] | 杨巍 白璐 宁俊义 董建军 单春海 信俊昌. 异构环境感知的幂律图流划分方法[J]. 《计算机应用》唯一官方网站, 0, (): 0-0. |
[9] | 秦学程 刘春颜 李宝 赵蕴龙. 面向工业场景的云边协同数据存储与检索架构[J]. 《计算机应用》唯一官方网站, 0, (): 0-0. |
[10] | 涂进兴, 李志雄, 黄建强. 基于GPU对角稀疏矩阵向量乘法的动态划分算法[J]. 《计算机应用》唯一官方网站, 2024, 44(11): 3521-3529. |
[11] | 孙鉴, 马宝全, 吴隹伟, 杨晓焕, 武涛, 陈攀. 地震场景下无人机群路径规划与任务分配均衡联合优化[J]. 《计算机应用》唯一官方网站, 2024, 44(10): 3232-3239. |
[12] | 蒋辉, 闫秋艳, 姜竹郡. 面向多元时间序列异常检测的对称正定自编码器方法[J]. 《计算机应用》唯一官方网站, 2024, 44(10): 3294-3299. |
[13] | 李源, 林秋兰, 陈安之, 杨国利, 宋威, 王国仁. 基于树分解的时序最短路径计数查询算法[J]. 《计算机应用》唯一官方网站, 2024, 44(8): 2446-2454. |
[14] | 田润泽, 周宇龙, 朱洪, 薛岗. 基于局部信息的服务迁移路径选择算法[J]. 《计算机应用》唯一官方网站, 2024, 44(7): 2168-2174. |
[15] | 宋洪涛, 于江生, 韩启龙. 工业多元时序数据质量评估方法[J]. 《计算机应用》唯一官方网站, 2024, 44(6): 1743-1750. |
阅读次数 | ||||||
全文 |
|
|||||
摘要 |
|
|||||