# Incorporating Code Structure and Quality in Deep Code Search
## 1 Introduction  
To develop software efficiently, software developers often find and reuse existing code snippets by searching over professional codebases, such as GitHub [1, 2, 3, 4]. Driven by information needs, developers will submit queries expressed in natural language and expect for code snippets satisfying their needs. However, code snippets and natural language queries are heterogeneous, and thus it is hard to locate code snippets that meet user's intent [5]. Traditional information retrieval methods toward code searching are usually based on text vocabulary matching [6]. For example, [PERSON] et al. [7] combined text similarity and API sequence matching and proposed an extended Boolean model named CodeHow. [PERSON] et al. [8] proposed Sourcerer, a code search tool that combines structural information with text vocabulary information using information retrieval techniques. Since code snippets and natural language queries have obvious heterogeneous characteristics [9, 10], code snippets that can fulfill information needs do not necessarily contain submitted query words or natural language words with similar semantics. As a result, the performance of traditional text vocabulary-based code search methods are greatly limited. [PERSON] et al. [11] brought joint embedding technology to code search to deal with the flaw and proposed a code search tool named DeepCS. The key idea of joint embedding technology is to transform heterogeneous inputs into shared vector space. With joint embedding technology, DeepCS embedded code snippets and natural language descriptions into a high-dimensional vector space. As a result, a code snippet and its corresponding description will occupy nearby regions of the space. By calculating the vector similarity of the embedded vectors of the code snippet and its corresponding description, code search tools can retrieve related code snippets that are more in line with users' expectations. With the development of machine learning technology in recent years, many different methods have gradually sprung up in the field of code search. [PERSON] et al. [2] proposed an unsupervised technique named Neural Code Search (NCS). NCS extracts specific keywords from code snippets and uses only the word embedding mechanism to obtain the vector of code snippets. [PERSON] [12] used Tree LSTM to process the abstract syntax tree of code snippets and proposed a new code search method named At-CodeSM. These methods used different techniques to extract the semantic features of code snippets and completed the code search task by comparing the similarity between vectors of code snippets and natural language queries. Although DeepCS showed quite good results on some datasets, we could still notice certain disadvantages. Firstly, DeepCS ignored certain structural information when representing code snippets, such as conditional statements and loop statements. Structural information reflects the execution order of code snippets, and thus is an essential part of code semantics [13]. DeepCS treated structural information as chain links, which ignores the semantics contained in the structure of code snippets, and thus limited the performance of code search. Secondly, DeepCS ignored the quality information of code snippets, such as naming clarity and logical correctness. The quality of codes from large codebases may vary. Take the two code snippets shown in Figure 1 as an example. The method name of the first code snippet cannot clearly reflect the purpose of this code, and the variable names in the second code snippet do not conform to naming conventions. Meanwhile, the purposes of the two code snippets are the same. That is to say, they should have a similar ranking order in the results returned by code search tools. However, when representing code snippets, DeepCS assigns the same weight value to all features, such as method names and tokens. As a result, the ranking order of the first code is far lower than that of the second code because of the incomprehensible method name.