科研 Skill
文体计量作者归属分析
stylometry-authorship-attribution
Performs stylometry and authorship attribution using word-frequency and n-gram methods like Burrows’ Delta. Use when a text’s authorship is disputed or anonymous.
SKILL.md
Stylometry and Authorship Attribution
Quantifies an author's writing style from function-word frequencies, character n-grams, and syntactic patterns, then compares a disputed or anonymous text against one or more candidate authors' known-genuine writing. Used in literary studies, history (forged or pseudonymous documents), classics, and digital humanities to support — never alone to prove — an authorship claim.
When to use
- A text's author is disputed, anonymous, or pseudonymous, and candidate authors with known writing samples exist (e.g. the Federalist Papers problem, disputed chapters in a multi-author work, a forged letter).
- A user asks "did X actually write this?", "whose style does this passage match?", or "is this consistent with the rest of the corpus?".
- Checking internal consistency of a claimed single-author corpus (did the author's style shift mid-career, or does one chapter look like a different hand?).
NOT for: plagiarism/duplicate-text detection (string matching, not style); genre or topic classification (that is about content, not authorial habit); proving authorship beyond reasonable doubt — stylometry produces probabilistic evidence, not proof.
Prerequisites
- Python 3.9+ with
scikit-learn,numpy,pandas, and optionallynltkorspacyfor tokenization. Install with:pip install scikit-learn numpy pandas nltk - At least 2,000–3,000 words per candidate author in known-genuine samples. Shorter samples make frequency counts noisy and widen the error bars on any attribution.
- The disputed text and all candidate samples in the same language and, as far as possible, the same genre/register — style markers conflate with genre and translation effects otherwise (a translated text mixes the translator's style into the signal).
- A plain-text or lightly-cleaned version of every document (strip running headers, footnotes, editorial apparatus, page numbers — these are not the author's prose).
Core method: Burrows' Delta
The most widely used and best-validated baseline for authorship attribution.
- Build the frequency table. For each document, count the relative frequency of the top N most frequent words across the whole corpus (typically the 100–500 most frequent words — in practice these are mostly function words: articles, pronouns, prepositions, conjunctions — the words an author uses unconsciously and cannot easily imitate).
import re
from collections import Counter
import numpy as np
import pandas as pd
def tokenize(text):
return re.findall(r"[a-zA-Z']+", text.lower())
def relative_frequencies(tokens, vocabulary):
counts = Counter(tokens)
total = len(tokens)
return {w: counts.get(w, 0) / total for w in vocabulary}
def build_frequency_table(documents: dict, n_most_frequent=200):
"""documents: {doc_id: raw_text}"""
all_tokens = {doc_id: tokenize(text) for doc_id, text in documents.items()}
corpus_counts = Counter()
for tokens in all_tokens.values():
corpus_counts.update(tokens)
vocabulary = [w for w, _ in corpus_counts.most_common(n_most_frequent)]
rows = {doc_id: relative_frequencies(toks, vocabulary)
for doc_id, toks in all_tokens.items()}
return pd.DataFrame(rows).T # rows = documents, columns = vocabulary
- Z-score the table. Delta compares documents in units of standard deviation per word, not raw frequency, so rare and common words are weighted comparably:
def zscore_table(freq_table: pd.DataFrame) -> pd.DataFrame:
return (freq_table - freq_table.mean()) / freq_table.std(ddof=0)
- Compute Delta between the disputed text and each candidate's known samples — mean absolute difference of z-scores across the chosen words:
def burrows_delta(z_table: pd.DataFrame, disputed_id: str) -> pd.Series:
disputed = z_table.loc[disputed_id]
others = z_table.drop(index=disputed_id)
delta = (others - disputed).abs().mean(axis=1)
return delta.sort_values() # lowest Delta = closest stylistic match
Lowest Delta wins — but report the gap between the best and second-best candidate, not just the winner. A narrow gap (e.g. 1.02 vs 1.05) is weak evidence; a wide one (1.0 vs 2.5) is stronger.
Complementary methods
- Character n-grams (3–5 character sequences, including spaces/punctuation)
capture morphology and spelling habits; more robust than word frequency
across genre shifts and short texts. Use
sklearn.feature_extraction.text. CountVectorizer(analyzer="char", ngram_range=(3,5)). - General Imposters method (Koppel & Winter) — the field's current
best-practice for verification (is text T by author A, yes/no — not a
closed-set pick among candidates). Compares the disputed text against the
true candidate plus many "imposter" authors of similar genre/period; the
attribution is credible only if it beats imposters consistently across
repeated random feature subsets. Implemented in the R package
stylo(functionimposters()) — the standard tool in digital-humanities stylometry; if only Python is available, replicate the logic with repeated random sub-sampling of the vocabulary and a distance-ratio threshold. - Principal Component Analysis / hierarchical clustering on the z-scored frequency table, to visualise whether a disputed text clusters with the claimed author's known work or sits between two candidates — good for presenting results, not a standalone attribution method.
Procedure
- Collect known-genuine samples per candidate author; confirm their authenticity is not itself in question.
- Normalise all texts identically (tokenization, case-folding, strip non-authorial material).
- Run Burrows' Delta and character n-gram distance; check whether they agree.
- If a closed-set attribution is wanted, also run General Imposters for verification against the top candidate.
- Report: the ranked candidates, the Delta gap, cross-validation stability (does splitting a candidate's samples into two halves still attribute them to "the same author"?), and any genre/register confound.
- State the finding as probabilistic — "the evidence favours attribution to X over the alternative candidates tested" — never as proof. Historical and literary authorship claims require corroborating non-stylometric evidence (manuscript provenance, contemporary testimony, documented access) before publication.
Quality checks
- Sanity check with known pairs: before trusting a result on the disputed text, run the method on two texts of known authorship from the same candidates and the same genre; it should recover the correct author. If it cannot pass this control, do not trust it on the disputed case.
- Control for length: compare documents of similar length, or normalise (Delta already works on relative frequencies, but very short disputed texts — under ~500 words — are unreliable regardless of method).
- Control for genre/register: a letter vs. a treatise by the same author will differ stylistically more than two treatises by different authors in the same genre. Say so explicitly if candidates' samples differ in genre from the disputed text.
- Report the alternative explanation: co-authorship, heavy editorial revision, dictation, and translation all weaken or invalidate a single-author stylometric signal — name this as a limitation whenever the historical record leaves it open.
Limitations
- Stylometry attributes style, not intent or authenticity — a skilled imitator or a later forger copying period style can defeat word-frequency methods; character-level and syntactic features are harder (not impossible) to fake.
- Results depend heavily on sample size and genre matching; a confident-looking Delta ranking from short or mismatched samples is not reliable evidence.
- These methods are validated mainly on Western alphabetic languages (English, German, French, Latin); for agglutinative, logographic or heavily inflected languages, tokenization and the function-word assumption may not transfer without adaptation — check published stylometric work in that specific language family before trusting default settings.
- This skill does not replace codicological, documentary, or historical evidence for authorship; it produces one line of quantitative evidence to weigh alongside those.
示例提示词
帮我用词频和字符n-gram方法比较这篇匿名文稿和候选作者的写作风格。
所属插件
安装该插件会一并获得同领域的 62 个 Skill / MCP。
同插件的其他科研 Skill
- 学术文献获取下载Auto-downloads open-access PDFs for graded sources and writes a manual worklist for paywalled items. Use after literature-review, before ingest-source.
- 单篇文献入库管理Adds one verified PDF to a shared bibliography library, computing its citation key and keywords. Use to register a single document outside the full workflow.
- 数字人文计算方法Surveys computational DH methods: text mining, NLP, corpus linguistics, archive standards, GIS, network analysis, and OCR. Use for an overview of available DH tools.
- 考古地理信息系统分析Runs archaeological GIS analysis with GeoPandas: catchment analysis, viewshed, kernel density, spatial statistics. Use for mapping archaeological site locations.
- 论证结构提取可视化Extracts and visualizes argument structure: Toulmin reconstruction, support/attack graphs, circularity detection. Use to diagram an argument’s logical structure.
- 考古遗物类型学分析Performs artifact analysis: typological classification, ceramic attribute coding, lithic reduction analysis. Use when classifying excavated artifacts statistically.
- 引文与出处核查Checks citations, quotations, page numbers, and bibliography entries for accuracy and source fit. Use before submission to verify source-supported claims.
- 研究选题构思设计Explores research intent, field state, methodology, and ethics, then writes an approved design doc. Use before starting a new research question or chapter.
- 术语译名一致性检查Audits a manuscript for terms, translations, abbreviations, and names whose forms must stay stable. Use when terminology drift could undermine an argument.
- 计算语用学分析Runs computational pragmatics: speech act classification, implicature detection, discourse coherence, politeness analysis. Use for language-use-and-meaning studies.
- 文献综述学术对话构建Turns verified sources into a structured scholarly conversation among positions, not a chronological summary. Use when synthesizing literature into a debate narrative.
- 语料库语言学分析Performs corpus analysis with NLTK/spaCy: collocation, keyword analysis, KWIC concordance, word2vec, diachronic trends. Use for quantitative text-corpus research.
- 数字档案馆资源检索Queries digital archive REST APIs: Europeana, Chronicling America, Internet Archive, HathiTrust, DPLA, OAI-PMH. Use when searching or harvesting heritage metadata.
- 学术手稿章节撰写Drafts a chapter or article section by section from synthesized wiki content, agreeing each section’s argument first. Use to turn stable research synthesis into prose.
- 研究项目漂移状态检测Checks a shared source library and registered projects for drift: un-indexed PDFs, unmerged keywords, bibkey collisions. Use to audit a multi-project research setup.
- EMI课堂语料转写分析Segments and annotates classroom transcripts, coding language choice and discourse function with anonymised output. Use to quantify classroom talk or translanguaging.
- 人工智能伦理分析Analyzes AI ethics: algorithmic fairness metrics, bias auditing, value alignment, moral philosophy reasoning. Use to evaluate an AI system’s ethical dimensions.
- 研究计划任务执行Executes a ready research plan task by task, gating acquisition before ingest and dispatching analysis. Use after writing-research-plan to run the planned work.
- 研究项目结项清单Runs the final completion checklist: rendering, bibliography, wiki, data, reproducibility, archiving. Use when a manuscript is finalized and ready to publish.
- 形式逻辑自动推理Applies formal logic tools: Z3 SMT solver, modal logic S5, SAT encoding, Lean4 proof verification. Use to formalize or mechanically check a logical argument.
- 研究问题凝练构建Turns a broad topic or intuition into a precise, contestable, researchable question. Use at the start of a project when no defensible question yet exists.
- 历史地理信息系统分析Performs historical GIS work: georeferencing old maps, digitizing boundaries, temporal territory overlays, population interpolation. Use for historical spatial analysis.
- 历史语言学比较分析Analyzes historical linguistics in Python: sound correspondences, cognate detection, phylogenetic trees, Swadesh lists. Use when reconstructing language relationships.
- 历史社会网络分析Builds historical network analyses: correspondence networks, prosopography, temporal community detection, Gephi export. Use to map relationships among historical actors.
常见问题
文体计量作者归属分析能做什么?
Performs stylometry and authorship attribution using word-frequency and n-gram methods like Burrows’ Delta. Use when a text’s authorship is disputed or anonymous。
如何安装文体计量作者归属分析?
在科搭 Codar 左侧点击「插件」,在「组件」页签搜索「文体计量作者归属分析」并安装;在 Claude Code 或 Codex 中可以发送本页的安装提示词,或下载 Skill 包后解压到 ~/.claude/skills 或 ~/.codex/skills。
文体计量作者归属分析需要哪些权限?
该科研 Skill没有声明额外权限;执行具体操作时仍由 Agent 按自身规则请求确认。
文体计量作者归属分析经过官方审核吗?
是。SpeedSkills 收录的每个版本都会记录内容摘要与权限声明,当前版本已通过安全审核。