[Paper Review] Machine Learning Based Source Code Classification Using Syntax Oriented Features
This paper proposes a machine learning approach for automatic programming language identification using syntax-oriented features extracted from source code. By modeling grammar productions as features and training a Maximum Entropy classifier, the method achieves 99% accuracy in identifying 29 popular programming languages, meeting key criteria for production use including accuracy, coverage, extensibility, and performance.
As of today the programming language of the vast majority of the published source code is manually specified or programmatically assigned based on the sole file extension. In this paper we show that the source code programming language identification task can be fully automated using machine learning techniques. We first define the criteria that a production-level automatic programming language identification solution should meet. Our criteria include accuracy, programming language coverage, extensibility and performance. We then describe our approach: How training files are preprocessed for extracting features that mimic grammar productions, and then how these extracted grammar productions are used for the training and testing of our classifier. We achieve a 99 percent accuracy rate while classifying 29 of the most popular programming languages with a Maximum Entropy classifier.
Motivation & Objective
- To address the limitations of manual or extension-based programming language identification in large codebases.
- To develop a fully automated, scalable solution for source code language classification that meets production-level requirements.
- To improve accuracy and coverage across diverse programming languages using grammar-inspired features.
- To ensure extensibility and high performance for real-world deployment in software engineering tools.
Proposed method
- Extracting syntax-oriented features by parsing source code files to identify grammar-like production rules.
- Transforming these grammar productions into numerical features suitable for machine learning.
- Training a Maximum Entropy classifier on the extracted features using labeled training data.
- Validating the model on a diverse dataset of 29 popular programming languages.
- Preprocessing files to normalize and standardize feature representation before classification.
- Using a structured feature representation that mimics syntactic constructs to improve discriminative power.
Experimental results
Research questions
- RQ1Can a machine learning model achieve high accuracy in classifying source code into programming languages using syntax-aware features?
- RQ2How well does the proposed method generalize across a broad set of 29 popular programming languages?
- RQ3Does the use of grammar-inspired features outperform traditional methods based on file extensions or simple token counts?
- RQ4Can the system maintain high performance and scalability while remaining extensible to new languages?
Key findings
- The proposed method achieves a 99% accuracy rate in classifying 29 popular programming languages.
- The Maximum Entropy classifier demonstrates strong generalization and robustness across diverse language syntaxes.
- Syntax-oriented features significantly improve classification performance compared to heuristic or extension-based methods.
- The system satisfies key production-level criteria, including high accuracy, broad language coverage, and extensibility.
- The approach is efficient and scalable, suitable for integration into large-scale software analysis pipelines.
Read this paper
Open the full text in the Nubint reader and ask about any passage as you read.
Read this paper on NubintThis review was generated by AI from the original paper. Please check the paper before citing it.