toy
This commit is contained in:
parent
73375c0507
commit
0a5c7b535d
|
|
@ -14,3 +14,8 @@ Cargo.lock
|
|||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
|
||||
|
||||
# Added by cargo
|
||||
|
||||
/target
|
||||
|
|
|
|||
|
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "john_slop"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
miette = { version = "7.6.0", features = ["fancy"] }
|
||||
thiserror = "2.0.17"
|
||||
|
|
@ -1,3 +1,9 @@
|
|||
# JohnSlop
|
||||
|
||||
Detect AI slop markers
|
||||
Detect AI slop markers
|
||||
|
||||
|
||||
# Links
|
||||
* [https://en.wikipedia.org/wiki/Wikipedia%3ASigns_of_AI_writing]
|
||||
* [https://en.wikipedia.org/wiki/Wikipedia:WikiProject_AI_Cleanup]
|
||||
* [https://www.theverge.com/report/756810/wikipedia-ai-slop-policies-community-speedy-deletion]
|
||||
|
|
|
|||
|
|
@ -0,0 +1,63 @@
|
|||
// ──────────────────────────────────────────────────────────────────────
|
||||
// Cargo.toml
|
||||
// ──────────────────────────────────────────────────────────────────────
|
||||
// [dependencies]
|
||||
// miette = "7"
|
||||
// ──────────────────────────────────────────────────────────────────────
|
||||
|
||||
use miette::{LabeledSpan, miette};
|
||||
|
||||
/// Creates a diagnostic for the ambiguous Unicode character U+2011
|
||||
/// (non‑breaking hyphen) that can be confused with the ordinary hyphen U+002D.
|
||||
fn unicode_confusion_report() -> miette::Report {
|
||||
// The source text you want to annotate
|
||||
let source = "Validate that the configuration file at path is well‑formed.".to_string();
|
||||
|
||||
// Build the report
|
||||
miette!(
|
||||
// Label the exact character that is problematic (index 52 in the string)
|
||||
labels = vec![LabeledSpan::at(52..53, "non‑breaking hyphen U+2011")],
|
||||
// Help text that tells the user what to do
|
||||
help = "This file contains ambiguous Unicode characters that might be \n\
|
||||
confused with other characters. This is often the mark of AI\n\
|
||||
generated text.",
|
||||
// Short description shown in the diagnostic title
|
||||
"Ambiguous Unicode character detected"
|
||||
)
|
||||
// Attach the source code to the report so that miette can pretty‑print it
|
||||
.with_source_code(source)
|
||||
}
|
||||
|
||||
/// Creates a diagnostic for text that looks like it was generated by an AI,
|
||||
/// because it contains the phrase “as of my last knowledge update”.
|
||||
fn ai_generated_report() -> miette::Report {
|
||||
// The source text you want to annotate
|
||||
let source = "As of my last knowledge update in January 2022, a historic \n
|
||||
peace agreement between the Colombian government and the \
|
||||
Revolutionary Armed Forces of Colombia"
|
||||
.to_string();
|
||||
|
||||
// Build the report
|
||||
miette!(
|
||||
// Label the suspicious phrase (roughly the first 34 characters)
|
||||
labels = vec![LabeledSpan::at(0..34, "\"as of my last knowledge update\"")],
|
||||
help = "If the text contains phrases like \"as an AI model\" or \"as of my \n\
|
||||
last knowledge update\", or if the editor copy‑pasted the \n\
|
||||
prompt used to generate the text together with the AI \n\
|
||||
response, the text is almost certainly AI‑generated.",
|
||||
"Potential AI‑generated content detected"
|
||||
)
|
||||
.with_source_code(source)
|
||||
}
|
||||
|
||||
fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Show the Unicode‑confusion diagnostic
|
||||
let report1 = unicode_confusion_report();
|
||||
println!("{:?}\n", report1);
|
||||
|
||||
// Show the AI‑generated‑text diagnostic
|
||||
let report2 = ai_generated_report();
|
||||
println!("{:?}", report2);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Reference in New Issue