# Joint Embedding of Semantic and Statistical Features for Effective Code Search
## 1 Introduction  
Code search is a process that takes a user's query as input and retrieves the most relevant, appropriate and rated source code snippets from a code base [1]. During software development, 19% of working time is spent on code search, the existing code snippets in open-source communities can be reused to implement current requirements [2]. An effective code search approach can significantly improve the efficiency of software development [3, 4, 5]. Existing code search research mainly focuses on query expansion and search engine optimization, which are constructed based on semantic and statistical features. [PERSON] et al. used semantics and ordering to retrieve source code [6]. [PERSON] conducted instance queries from large-scale code repositories [7]. The effectiveness of semantic and statistical analysis can directly impact code search techniques. However, existing code search techniques focus on either semantic or statistical model, regardless of the potential relationships between them. For example, API invocation and code frequency can represent a code snippet from different perspectives, but they are rarely used together in traditional code search approach. The existing works already prove that either statistical features [8] or semantic features [9, 10, 11] can be used to build a code search model. Actually, semantic and statistical features are symbiotic in software projects. Technical problems that arise when combining semantic and statistical features involves the mismatch between cooperative features and multidimensional information with various patterns of representation and different levels of granularity. To address this problem, we apply joint natural language and source code snippet models to make code search more effective, so that a code search technique can be found, i.e., JessCS. During code semantic analysis, the necessary semantic information is extracted at the method level and the class level to implement the best fit semantic information. Next, statistical features are extracted, e.g., API invocation sequence, to investigate statistical regularity. During joint embedding, the code and its corresponding natural language description are mapped into a unified vector space. Semantically, similar concepts occupyadjacent regions in this vector space. We train a deep learning model to match the natural language query and relate code based on the joint embedding network. To evaluate the effectiveness of JessCS, we collected 1,263,974 sets of code and a set of corresponding functional descriptions from a public API, i.e., Google BigQuery (Google BigQuery, [[https://cloud.google.com/bigquery/public-data/](https://cloud.google.com/bigquery/public-data/)]([https://cloud.google.com/bigquery/public-data/](https://cloud.google.com/bigquery/public-data/)) (accessed on 1 June 2020)). The code base is conducted based on a project filter that limits the stars, language, time period, and other factors. Methods that do not contain Javadoc comments are filtered out. Our model uses \(<\)method name, API invocation, token collection\(>\) to represent the code snippets. Experimental results show that JessCS obtained higher accuracy and success rate on code search results. We selected UNIF-based approach [12] to make the comparison. JessCS obtains commonly at least 13% improvement in various indicators, and the query success rate of returning TOP-10 results reaches 0.90. In terms of code feature selection, selecting a triad for the code feature improves the TOP-1 Precision and MRR (Mean Rank Reciprocal) by 16.6% and 0.144, respectively, which effectively improves the accuracy of code search. To summarize, the main contributions of this study include:  
* We propose semantic and statistical analysis methods for code search and combines deep learning to construct a joint embedding network. * A code search technique for Java language, i.e., JessCS is designed and a dataset for code search based on 1,263,974 pairs of code snippets and descriptions was constructed.