Content-Based Textual File Type Detection at Scale
Francesca Del Bonifro, Maurizio Gabbrielli, Stefano Zacchiroli

TL;DR
This paper presents a simple, scalable method for detecting file types based solely on textual content using N-gram features and neural networks, achieving high accuracy across many programming languages.
Contribution
It introduces a language-agnostic N-gram based neural classifier for file type detection that works without relying on file extensions.
Findings
Achieves 85% accuracy across 130+ file types
Effective in classifying files without extensions
Simple model suitable for large-scale analysis
Abstract
Programming language detection is a common need in the analysis of large source code bases. It is supported by a number of existing tools that rely on several features, and most notably file extensions, to determine file types. We consider the problem of accurately detecting the type of files commonly found in software code bases, based solely on textual file content. Doing so is helpful to classify source code that lack file extensions (e.g., code snippets posted on the Web or executable scripts), to avoid misclassifying source code that has been recorded with wrong or uncommon file extensions, and also shed some light on the intrinsic recognizability of source code files. We propose a simple model that (a) use a language-agnostic word tokenizer for textual files, (b) group tokens in 1-/2-grams, (c) build feature vectors based on N-gram frequencies, and (d) use a simple fully connected…
Peer Reviews
No public reviews on file for this paper yet. If you reviewed it on a platform where reviews are public (OpenReview, ICLR, NeurIPS, ICML), you can paste yours below so the community can read it here.
Videos
No videos yet. Explain this paper in a talk, walkthrough, or lecture? Add one.
