
The Thirtieth AAAI Conference on Innovative Applications of Artificial Intelligence (IAAI-18) Discovering Program Topoi through Clustering Carlo Ieva,1,2 Arnaud Gotlieb,1 Souhila Kaci,2 Nadjib Lazaar2 1SIMULA Research Laboratory, Oslo, Norway 2LIRMM, University of Montpellier, France {carlo, arnaud}@simula.no, {souhila.kaci, nadjib.lazaar}@lirmm.fr Abstract functions entry points and the sorting criterion is based on the distance between common functions and entry points. Understanding source code of large open-source software The whole method can be summarized according to its three projects is very challenging when there is only little docu- mentation. New developers face the task of classifying a huge main steps: number of files and functions without any help. This paper 1. Preprocessing. Source code, with its comments, is parsed documents a novel approach to this problem, called FEAT, generating for every code unit (either functions in proce- that automatically extracts topoi from source code by using dural languages or methods in object oriented ones) a cor- hierarchical agglomerative clustering. Program topoi summa- responding textual document. Additionally, a graph rep- rize the main capabilities of a software system by present- ing to developers clustered lists of functions together with resentation of the caller-callee relationship (call graph) is an index of their relevant words. The clustering method used also created in this step. in FEAT exploits a new hybrid distance which combines 2. Clustering. Code units are grouped together by means of both textual and structural elements automatically extracted hierarchical agglomerative clustering (HAC). from source code and comments. The experimental evalu- ation of FEAT shows that this approach is suitable to un- 3. Entry Point Selection. Within the context of every cluster, derstand open-source software projects of size approaching code units are ranked and those placed in higher positions 2,000 functions and 150 files, which opens the door for its will constitute a program topos. deployment in the open-source community. The contribution of this paper is three-fold: Introduction 1. FEAT is a novel, fully automated approach for program topoi extraction based on clustering units directly from The development of large-scale open-source projects in- source code. To exploit HAC, we propose an original hy- volves many distinct developers contributing to the creation brid distance combining structural and semantic elements of large code repositories. As an example, the July 2017 re- of source code. HAC requires the selection of a partition lease of the Linux kernel (v. 4.12), amounting to almost 20 among all those produced along the clustering process, MLOC (lines of code), requested the effort of 329 develop- our approach makes use of a hybrid criterion based on ers marking a growth of 1 MLOC respect to its predeces- graph modularity (Donetti and Munoz˜ 2004) and textual sor. This figures make clear that, whenever a new developer coherence (Foltz, Kintsch, and Landauer 1998) to auto- wants to become a contributor, he/she has to face the prob- matically select the appropriate one; lem of understanding a huge amount of code, organized as an unclassified set of files and functions. 2. Clusters of code units need to be analyzed to extract pro- Organizing the code in a more abstract way, closer to hu- gram topoi. We define a set of structural elements ob- mans is an attempt that received interest from the Software tained from source code and use them to create an alter- Engineering community. Unfortunately, there is no recog- native representation of clusters of code units. Principal nized recipe or tool that can concretely provide any help in Component Analysis (PCA), with its capability of dealing dealing with large software repositories. with multi-dimensional data, provides us a way to mea- We propose an effective solution to this problem by auto- sure the distance of code units respect to an ideal entry matically extracting program topoi which are ordered lists of point. This distance is the basis for code units’ ranking function names associated with an index of relevant words. shown to end-users. How does the sorting take place? FEAT does not con- 3. We implemented FEAT on top of a general-purpose soft- sider all functions as equal: some of them are considered ware analysis platform and performed an experimental like a gateway to the implementation of high-level, user- study over some open-source software projects. During observable capabilities of a program. We call these special the evaluation we analyzed FEAT under several perspec- Copyright © 2018, Association for the Advancement of Artificial tives: the clustering step, effectiveness in topoi discovery Intelligence (www.aaai.org). All rights reserved. and, scalability of the approach. 7771 Related work ploits both text mining and code structure analysis to guide Our research spans the domain of program understanding the creation of clusters. focusing mainly on feature extraction (Rubin and Chechik We believe that there are several differences between 2013; Chen and Rajlich 2000; Marcus and Haiduc 2013) FEAT and the above mentioned approaches and that FEAT that aims to automatically discover the main characteristics fosters program understanding by creating a novel hybrid of a software system by analyzing source code or other arti- approach blending structural and semantic aspects of source facts. It must be distinguished from feature location, whose code. objective is to locate where and how these characteristics are implemented (Rubin and Chechik 2013). Feature lo- cation requires the user to provide an input query where Background the searched characteristic is already known, while feature extraction tries to automatically discover these characteris- Software Clustering tics. Since several years, software repository mining is con- sidered mainstream in feature extraction. However, we can Software clustering methodologies create group of entities, distinguish between software-repository mining approaches such as classes, functions, etc. of a software system in order dealing with software documentation only and, those deal- to ease the process of understanding the high-level structure ing with source code only. of a large and complex software system (Shtern and Tzerpos Mining Software Documentation. In (Dumitru et al. 2012). The basis for any cluster analysis to group entities is ), both text-mining techniques and flat clustering are used their set of attributes. to extract feature descriptors from user requirements kept The application of clustering to a software system re- in software repositories. By combining association-rules quires the identification of the entities which are the object mining and k-Nearest-Neighbour, the proposed approach of the grouping. Several artifacts can be chosen but the most makes recommendations on other feature descriptors to popular one is source code (Mitchell 2003). The selection strengthen an initial profile. More recently (McBurney, Liu, of entities is affected by the objective of the method. For and McMillan 2016) presented four automatic generators of program restructuring at a fine-grained level, function call list of features for software projects, which select English statements are chosen as entities (Xu et al. 2004) while for sentences that summarize features from the project docu- design recovery problems (Andritsos and Tzerpos 2005) en- mentation. tities are often software modules but also classes or routines. FEAT has two distinguishing elements w.r.t. these tech- Extracting facts from source code can be done follow- niques. Firstly, FEAT deals with both software documen- ing two different conceptual approaches: structural and se- tation and source code by applying at the same time code mantic. Structure-based, approaches rely on static relation- and text analysis techniques. Secondly, FEAT uses HAC as- ships among entities: variable references, procedure calls, suming that software functions are organized according to a inheritance etc. Semantic approaches take into account the certain (hidden) structure that can be automatically discov- domain knowledge information contained in source code ered. and extracted from comments and identifier names (Kuhn, Mining Source Code. (Linstead et al. 2007) proposes Ducasse, and Gˆırba 2005). The software clustering commu- dedicated probabilistic models based on code analysis us- nity widely adopts structure-based approaches but it has to ing Latent Dirichlet Allocation to discover features under the be noted that the output produced by semantic approaches form of so-called topics (main functions in code). (McMillan tends to be more meaningful. That is why some try to com- et al. 2012) present a source-code recommendation system bine the strengths of both methods like (Tzerpos and Holt for software reuse. Based on a feature model (a notion used 2000). in product-line engineering and software variability model- ing), the proposed system tries to match the description with The actual cluster creation is accomplished through a relevant features in order to recommends the reuse of exist- clustering algorithm. Clustering is the most common form ing source code from open-source repositories. (Abebe and of unsupervised learning and the key input to a clustering Tonella 2015) proposes natural language parsing to automat- algorithm is the distance measure. Different distance mea- ically extract an ontology from source code. Starting from a sures
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-