[Paper Review] Natural Language or Not (NLoN) - A Package for Software Engineering Text Analysis Pipeline
This paper introduces NLoN, an open-source R package that classifies software engineering text as natural language or not using 11 linguistic features and character tri-grams. Trained with Lasso regression, it achieves AUC scores between 0.976 and 0.987 on three distinct data sources (Mozilla, Kubernetes, Lucene), offering a lightweight, reusable solution for NLP preprocessing in software engineering pipelines.
The use of natural language processing (NLP) is gaining popularity in software engineering. In order to correctly perform NLP, we must pre-process the textual information to separate natural language from other information, such as log messages, that are often part of the communication in software engineering. We present a simple approach for classifying whether some textual input is natural language or not. Although our NLoN package relies on only 11 language features and character tri-grams, we are able to achieve an area under the ROC curve performances between 0.976-0.987 on three different data sources, with Lasso regression from Glmnet as our learner and two human raters for providing ground truth. Cross-source prediction performance is lower and has more fluctuation with top ROC performances from 0.913 to 0.980. Compared with prior work, our approach offers similar performance but is considerably more lightweight, making it easier to apply in software engineering text mining pipelines. Our source code and data are provided as an R-package for further improvements.
Motivation & Objective
- To address the challenge of distinguishing natural language from non-natural language text (e.g., code, logs, stack traces) in software engineering text mining pipelines.
- To develop a lightweight, reusable tool that avoids the complexity of existing solutions requiring database dumps or custom parsers.
- To enable efficient, low-effort adaptation of the classifier to new software projects with minimal manual labeling (~4 hours for 2,000 lines).
- To provide a machine learning-based alternative to regular expressions that generalizes better across diverse software engineering text sources.
- To support NLP tasks such as sentiment analysis and topic modeling by filtering out non-natural language content prior to processing.
Proposed method
- The NLoN package uses 11 linguistic features, including stop-word ratios, capital letter frequency, and punctuation counts, to characterize input text.
- It incorporates character tri-grams as a feature set to capture language-specific patterns, drawing from language detection literature.
- A Lasso regression model from the Glmnet library is trained on human-annotated data to classify each line as natural language or not.
- Ground truth is established by two human raters, with inter-rater agreement used to validate labeling quality.
- The model is trained on project-specific data (up to 2,000 lines) and evaluated using 10-fold cross-validation and cross-source prediction.
- The tool is implemented as an open-source R package, enabling easy integration and extension in software engineering text analysis pipelines.
Experimental results
Research questions
- RQ1Can a lightweight, machine learning-based classifier effectively distinguish natural language from non-natural language text in software engineering artifacts?
- RQ2How well does the NLoN model generalize across different software engineering data sources (e.g., bug reports, chat logs, emails)?
- RQ3What is the performance of the NLoN model compared to prior work, especially in terms of AUC and computational simplicity?
- RQ4To what extent does using a shared model across multiple projects degrade performance compared to project-specific training?
- RQ5Can the model be effectively adapted to new projects with minimal human effort and without complex configuration?
Key findings
- The NLoN model achieves an area under the ROC curve (AUC) between 0.976 and 0.987 when trained and tested on data from three distinct software projects: Mozilla Firefox, Kubernetes, and Apache Lucene.
- Cross-source prediction performance is lower but still strong, with AUC ranging from 0.913 to 0.980, indicating good generalization potential, though performance varies by source direction.
- Using all available data for training does not improve or degrade performance compared to using project-specific data, suggesting that the model’s generalization is robust.
- The model performs best when trained on data from the same source it is applied to, with the highest AUC of 0.987 on Mozilla issue comments and 0.981 on Lucene emails.
- The model’s performance remains high (AUC 0.980) when predicting Mozilla issue comments using data from Kubernetes chat messages, indicating strong cross-project transferability in some directions.
- Despite strong performance, cross-prediction from Mozilla comments and Kubernetes chat to Lucene emails yields the weakest result (AUC 0.913), suggesting domain-specific differences affect model generalization.
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.