Views
No views yet
┌─────────────────────────────────────────────────────────┐
│ Gradio UI (app.py) │
│ ┌──────────────┐ ┌─────────────────────────────────┐ │
│ │ Reference PDF │ │ Target Draft (paste) │ │
│ │ or Text │ │ │ │
│ └──────┬───────┘ └────────────┬────────────────────┘ │
│ │ │ │
│ ▼ ▼ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ rewrite_agent.py — CodeAgent │ │
│ │ │ │
│ │ Step 1: style_extractor(reference) → ref_metrics│ │
│ │ Step 2: style_extractor(target) → tgt_metrics│ │
│ │ Step 3: Rewrite target to match ref_metrics │ │
│ │ Step 4: style_extractor(rewritten) → verify │ │
│ │ │ │
│ │ ┌─────────────────────────────────────────────┐ │ │
│ │ │ style_extractor.py — Tool │ │ │
│ │ │ │ │ │
│ │ │ • Sentence Length Variance (σ) │ │ │
│ │ │ • Hedging Density (per sentence) │ │ │
│ │ │ • Passive Voice Density (per sentence) │ │ │
│ │ └─────────────────────────────────────────────┘ │ │
│ └──────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────────────────────────────────┐ │
│ │ Rewritten Text + Metrics │ │
│ └──────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────┘| Metric | Description | Academic Signature |
|---|---|---|
| Sentence Length Variance | σ of word counts per sentence | High variance = mix of short and long multi-clause sentences |
| Hedging Density | Hedge words per sentence (suggest, may, putative, indicate, could...) | Pre-2022 manuscripts hedge heavily in Results/Discussion |
| Passive Voice Density | Academic passive constructions per sentence (was performed, were analyzed...) | Methods sections are dominated by passive voice |
1pip install -r requirements.txt
2export HF_TOKEN="hf_..." # your Hugging Face token
3python app.py # launches Gradio on http://localhost:7860manuscript_mimic/
├── __init__.py # Package marker
├── style_extractor.py # StyleExtractorTool + metric functions
├── rewrite_agent.py # CodeAgent orchestrator + run_mimic()
├── app.py # Gradio web UI
├── requirements.txt # Dependencies
└── README.md # This file1from style_extractor import extract_style_metrics
2from rewrite_agent import run_mimic
3
4# Analyze a text
5metrics = extract_style_metrics("Your academic text here...")
6print(metrics)
7
8# Rewrite to match a reference
9rewritten = run_mimic(
10 reference_text="Pre-2022 manuscript excerpt...",
11 target_text="AI-generated draft...",
12)
13print(rewritten)Qwen/Qwen2.5-Coder-32B-Instruct (default — best for code-generation agents)meta-llama/Llama-3.3-70B-Instructmistralai/Mixtral-8x7B-Instruct-v0.1