From Stylometry to Authorship Attribution: How Technical Analysis Determines "Who Really Wrote This"
This article explains how the question "was this text ghostwritten?" can be framed as a rigorous machine learning problem. It covers the theoretical foundations of stylometry (style fingerprints), key feature categories such as function-word distributions and syntactic patterns, three technical approaches ranging from classical statistics to deep learning, and why a multi-source evidence chain is essential. It also outlines practical engineering considerations and the fundamental limits of what text forensics can and cannot prove.
1. Background: Why “Ghostwriting” Disputes Are Fundamentally a Technical Problem
In online public discourse, disputes over “whether a work was really written by the claimed author” are common. In the past, such debates mostly stayed at the level of emotional speculation: some people compared perceived “style differences,” others dug up timeline inconsistencies, and still others pointed to the person’s later public behavior. All of these approaches have obvious flaws. Subjective impressions cannot be quantified, isolated evidence cannot form an evidence chain, and a person’s later conduct does not necessarily correspond strictly to their earlier writing ability.
From a technical perspective, this class of problems can be abstracted into a classic machine learning task: authorship attribution. Given a set of reference texts with known authors and a text of unknown origin, the goal is to determine the true author of the latter. When the question is extended to “was this passage written independently by a human, ghostwritten by someone else, or generated with AI assistance,” it becomes an intersection of authorship attribution and AI-generated text detection.
This article does not draw conclusions about any specific event or individual. Instead, it takes a neutral technical perspective to break down a complete methodology for text provenance analysis, explaining what such analysis “can do and cannot do.”
2. Core Principles: What Is a “Style Fingerprint”
The theoretical foundation of style fingerprints is stylometry. Its basic assumption is that every person develops relatively stable, unconscious linguistic habits over long-term writing. These habits manifest in subtle details rather than in overt vocabulary choices or rhetorical style.
A reliable stylistic feature system typically includes the following levels:
1. High-frequency function word distribution
The usage frequency and collocation patterns of function words (particles, conjunctions, auxiliaries, prepositions) are the features an author finds hardest to deliberately disguise. A ghostwriter can imitate subject matter and viewpoints, but it is extremely difficult to precisely reproduce another person’s function-word statistical distribution over a sustained body of text.
2. Syntactic structure features
Average sentence length, sentence length variance, clause nesting depth, punctuation habits (preferences for semicolons, dashes, and so on), and passive voice ratio. These features can be extracted automatically through dependency parsing.
3. Character-level and lexical-level statistics
Character n-gram frequencies, lexical richness (such as TTR and Yule’s K), rare word distribution, and the density of idioms and loanwords.
4. Discourse organization features
Paragraph length distribution, transition patterns, and how argumentative structures unfold. These features are harder to extract automatically but carry substantial information in long-text comparisons.
One principle deserves emphasis: the more unconscious and harder a feature is to control deliberately, the higher its evidentiary value. Topic, opinion, and emotional tendency are all “easily faked” low-weight features and should not serve as primary evidence.
3. Technical Approaches: From Feature Engineering to Model Inference
3.1 Classical Statistical Methods
Early classic solutions compute similarity based on feature vectors. For example, extract the usage frequency vector of the top N most frequent characters and compute cosine similarity or chi-square distance:
import refrom collections import Counterdef char_freq(text, top_n=50):chars = re.sub(r'\s', '', text)cnt = Counter(chars)most = [c for c, _ in cnt.most_common(top_n)]total = len(chars)return {c: cnt[c] / total for c in most}def cosine_sim(v1, v2):keys = set(v1) | set(v2)num = sum(v1.get(k, 0) * v2.get(k, 0) for k in keys)den1 = sum(x*x for x in v1.values()) ** 0.5den2 = sum(x*x for x in v2.values()) ** 0.5return num / (den1 * den2) if den1 and den2 else 0
These methods are simple and interpretable, making them suitable for preliminary screening. However, they are sensitive to differences in text length and require normalization.
3.2 Machine Learning Classification
A more robust approach models the problem as supervised classification: collect multiple reliable text samples from each candidate author, extract unified features (such as TF-IDF-weighted function word vectors, syntactic features, and character n-grams), train a classifier (common choices include support vector machines, random forests, and gradient-boosted trees), and then output a probability for the disputed text.
Two engineering requirements are critical:
- Same-domain comparison: Training samples and the disputed text should be collected from similar writing periods and similar genres (e.g., all fiction or all essays). Otherwise, stylistic evolution over time and topic differences will severely distort results.
- Baseline control: You must include a “distractor author group” — run the same classification test across a large pool of other authors to verify whether the target author is genuinely distinguishable. If the classifier also achieves high accuracy on the distractor group, the features are separating “genre” rather than “author identity.”
3.3 Deep Learning and AI Detection
Recent approaches typically use pretrained language models to produce text representations, followed by a classification head for author discrimination; alternatively, the problem is framed as contrastive learning, training the model so that texts by the same author lie closer together in representation space. AI-generated content detection usually relies on statistics such as perplexity and burstiness, or on dedicated discriminative models. It must be stressed, however, that all current AI detection methods have non-negligible false positive rates — especially when text has been human-polished or produced through human-AI collaboration. Detection results in these scenarios can only serve as a reference signal, not as an independent conclusion.
4. Evidence-Chain Thinking: No Single Metric Constitutes a Conclusion
The most common mistake in text provenance practice is drawing conclusions from a single indicator. A rigorous approach builds a multi-source evidence chain:
- Quantitative stylistic analysis: Under controlled genre and time-period variables, report statistically meaningful similarity scores or classification probabilities, along with confidence intervals.
- Timeline and production capacity verification: Use creation timelines, text volume, and revision traces (such as differences across multiple draft versions) as auxiliary evidence — while acknowledging that these provide only indirect support.
- Cross-validation: Repeat experiments with different feature sets, different models, and different train/test splits to check whether conclusions remain stable.
- Adversarial testing: Proactively test robustness — for example, whether features fail when an author deliberately changes style, and how confidence degrades on short texts.
Even after completing this entire pipeline, a responsible conclusion should take a probabilistic form (e.g., “the two texts show significant differences in function-word distribution”) rather than an absolute “yes” or “no.” This is the essential difference between text forensics and fingerprint identification — textual features are both more controllable and more variable.
5. Practical Considerations for Engineering Implementation
- Data quality matters more than model complexity: Sample contamination (mixing in reposted content or editor-modified text) is more damaging than poor model selection.
- Avoid selection bias: Cherry-picking passages that “look different” for comparison systematically amplifies error — this is the most common trap in public-opinion text analysis.
- Compliance and ethics: Text analysis involving personal information must comply with applicable laws and regulations, and the public release of analytical conclusions should carefully weigh the impact on the individuals involved.
- Reproducibility: Publishing feature definitions, data processing pipelines, and evaluation metrics — and submitting them to peer scrutiny — is the only way for this kind of research to earn credibility.
6. Conclusion
“Was this text ghostwritten?” may look like a question of public opinion, but at its core it is an authorship attribution problem that can be rigorously technicized. Style fingerprints provide quantifiable analytical tools, and classical statistics, machine learning, and deep learning each have their applicable scenarios. However, any technical conclusion must be built on same-domain samples, baseline controls, cross-validation, and evidence-chain thinking — and presented in a probabilistic, reproducible manner. For developers and researchers, the value of mastering this methodology lies not only in responding to specific controversies, but also in understanding the boundaries of text forensics as a field: knowing what technology can prove is just as important as knowing what it cannot.
