Text Classification
Transformers
Safetensors
distilbert
spam-detection
email-classification
text-embeddings-inference
Instructions to use Pannuru/md-validator with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Pannuru/md-validator with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-classification", model="Pannuru/md-validator")# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForSequenceClassification tokenizer = AutoTokenizer.from_pretrained("Pannuru/md-validator") model = AutoModelForSequenceClassification.from_pretrained("Pannuru/md-validator", device_map="auto") - Notebooks
- Google Colab
- Kaggle
File size: 3,114 Bytes
cd6dbae | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | #!/usr/bin/env python3
"""Merge reviewed content into report.json.
Writing recovered Markdown (LaTeX, tables, diagrams) inside JSON means escaping every
backslash and quote, which is error-prone. Instead, write a plain Markdown "resolutions"
file and let this script merge it:
### @FIG-p4-1 done
**Figure 1 - Proposed Spam Detection Model.** ...transcription / Mermaid / description...
### @EQ-p5-1 done
$$\\chi^2 = \\sum \\frac{(O_i - E_i)^2}{E_i} \\tag{1}$$
### @TB-p6-1 done
(empty body = accept the auto-drafted table exactly as generated)
### @GFX-p1-1 skip: publisher logo, decorative
### @T-p3-2 skip: page furniture, not content
Rules
* `done` + body -> body becomes the recovered Markdown for that item
* `done` + no body -> keep what is already in the item (auto draft / auto text)
* `skip: reason` -> item is not appended (reason is logged in the appendix)
* Unknown ids are reported and ignored.
Usage: python resolve.py --report work/report.json --resolutions work/resolutions.md
"""
import argparse
import json
import re
import sys
HDR = re.compile(r"^###\s+@(\S+)\s+(done|skip)\b\s*:?\s*(.*)$", re.I)
def parse(text):
out, cur = {}, None
for line in text.replace("\r\n", "\n").split("\n"):
m = HDR.match(line)
if m:
cur = m.group(1)
out[cur] = {"verb": m.group(2).lower(), "reason": m.group(3).strip(), "body": []}
elif cur:
out[cur]["body"].append(line)
for v in out.values():
v["body"] = "\n".join(v["body"]).strip("\n").strip()
return out
def main():
ap = argparse.ArgumentParser()
ap.add_argument("--report", required=True)
ap.add_argument("--resolutions", required=True)
a = ap.parse_args()
rep = json.load(open(a.report, encoding="utf8"))
res = parse(open(a.resolutions, encoding="utf8").read())
by_id = {i["id"]: i for i in rep["items"]}
done = skipped = 0
for rid, r in res.items():
it = by_id.get(rid)
if not it:
print(f" ! unknown id {rid} (ignored)")
continue
if r["verb"] == "skip":
it["status"], it["skip_reason"] = "skipped", r["reason"] or "skipped by reviewer"
skipped += 1
continue
body = r["body"] or it.get("recovered_markdown") or it.get("draft_markdown") or ""
if not body.strip():
print(f" ! {rid}: marked done but there is no content (add a body) -> left open")
continue
it["recovered_markdown"], it["status"] = body, "done"
it.pop("skip_reason", None)
done += 1
rep["summary"]["items_open"] = sum(1 for i in rep["items"] if i["status"] == "open")
json.dump(rep, open(a.report, "w", encoding="utf8"), ensure_ascii=False, indent=2)
print(f"resolved: {done} done, {skipped} skipped | still open: {rep['summary']['items_open']}")
for i in rep["items"]:
if i["status"] == "open":
print(f" open: {i['id']} ({i['type']}, p.{i['page']}, {i.get('label','')})")
if __name__ == "__main__":
sys.exit(main())
|