Documentation
¶
Overview ¶
Package check verifies a manuscript draft did not write: that its references name real works, its citations point at entries, and the works it cites say what it cites them for.
Every finding comes from a fixed rule over the manuscript's own text and what the lookups return; a model is asked only to propose a quote for the support check, and the quote is then held to the verbatim gate (refs/support). A reference no lookup could ask about is never reported as clean: Report.Unavailable says the check is incomplete.
Index ¶
- Constants
- Variables
- func ReadPDF(ctx context.Context, body []byte, ...) (string, error)
- func ValidFailOn(level string) bool
- func WriteSARIF(w io.Writer, version string, reports ...Report) error
- type DOIChecker
- type Finding
- type Labelled
- type Metrics
- type Options
- type Report
- type SourceTexts
- type Summary
- type Supporter
- type Texts
Constants ¶
const ( Error = "error" Warn = "warn" )
The severities a finding can have.
const ( RefFabricated = "REF-FABRICATED" RefMismatch = "REF-MISMATCH" RefAmbiguous = "REF-AMBIGUOUS" RefRetracted = "REF-RETRACTED" RefUnverifiable = "REF-UNVERIFIABLE" RefUncited = "REF-UNCITED" CiteDangling = "CITE-DANGLING" CiteUnsupported = "CITE-UNSUPPORTED" CiteWeak = "CITE-WEAK" NumUnsourced = "NUM-UNSOURCED" HedgeUpgrade = "HEDGE-UPGRADE" QuoteUnsourced = "QUOTE-UNSOURCED" Injection = "INJECTION" )
The finding codes. Each is documented with its rule in docs/check-report.md.
const ( FailFabricated = "fabricated" FailUnsupported = "unsupported" // every error, and CITE-UNSUPPORTED FailAny = "any" )
The --fail-on levels.
const ( ExitClean = 0 ExitFindings = 1 ExitUsage = 2 )
The exit codes of `draft check`.
const SARIFSchema = "https://json.schemastore.org/sarif-2.1.0.json"
SARIFSchema is the schema the SARIF report names.
const Schema = "draft.check-report/v1"
Schema names the report format, a stable contract (docs/check-report.md).
Variables ¶
var Rules = map[string]string{
RefFabricated: "A reference whose own identifier is false: a DOI no registration agency issued, or an arXiv id with no paper",
RefMismatch: "A reference whose DOI or arXiv id names a different work",
RefAmbiguous: "A reference two records match",
RefRetracted: "A reference to a retracted work",
RefUnverifiable: "A reference no lookup has a record of, without a false identifier",
RefUncited: "A reference-list entry no citation names",
CiteDangling: "A citation that names no entry of the reference list",
CiteUnsupported: "A citation whose work's full text had no passage the model found to state the sentence; check by hand",
CiteWeak: "A citation whose work's abstract does not state the sentence; its full text was not read",
NumUnsourced: "A number in no cited work, or not in the data file",
HedgeUpgrade: "A sentence that states as settled what the cited work hedges",
QuoteUnsourced: "A quotation not found in the cited work",
Injection: "Invisible characters, or text addressed to a model reading the manuscript",
}
Rules describes every finding code, as the SARIF report and the docs name it.
Functions ¶
func ReadPDF ¶
func ReadPDF(ctx context.Context, body []byte, extract func(context.Context, string) (string, error)) (string, error)
ReadPDF writes body to a temporary file and reads its text with extract; body must be a PDF, so a login page or an error page is refused rather than read as the work.
func ValidFailOn ¶
ValidFailOn reports whether level is a --fail-on level.
Types ¶
type DOIChecker ¶
DOIChecker asks whether a DOI was ever registered (resolve.Fetcher.DOIExists).
type Finding ¶
type Finding struct {
Code string `json:"code"`
Severity string `json:"severity"`
// Line is the line of the extracted text the finding is on, from 1; 0
// when it concerns the reference list as a whole.
Line int `json:"line,omitempty"`
Sentence string `json:"sentence,omitempty"`
// Reference is the entry concerned, as the list gives it.
Reference string `json:"reference,omitempty"`
Reason string `json:"reason"`
// Evidence is what the finding rests on: a record's address, a quote.
Evidence string `json:"evidence,omitempty"`
}
Finding is one thing wrong with the manuscript.
type Labelled ¶
Labelled is a reference whose truth is known: Fabricated when it was made up, as the evaluation set marks it.
type Metrics ¶
type Metrics struct {
TruePositives int `json:"true_positives"`
FalsePositives int `json:"false_positives"`
FalseNegatives int `json:"false_negatives"`
Precision float64 `json:"precision"`
Recall float64 `json:"recall"`
}
Metrics are how well REF-FABRICATED separates made-up references from real ones on a labelled set (plan WP-E3.4).
type Options ¶
type Options struct {
// Lookups resolve the references. None means every reference is
// unchecked.
Lookups []resolve.Lookup
// Offline says the lookups are local only, so a reference they do not
// know is unchecked, not unavailable.
Offline bool
// Bib is a bibliography the author vouches for; its entries join the
// manuscript's own list for citation markers.
Bib []refs.Reference
// Supporter and Texts run the support check; without both it is not run.
Supporter Supporter
Texts Texts
// DOIExists asks the DOI system about a DOI no lookup knows, so a
// DataCite DOI is not reported as made up. Without it such a DOI is
// unverifiable.
DOIExists DOIChecker
// Data is the text of a data file every stated number must appear in.
Data string
// Generator names the program, for the report.
Generator string
}
Options are what the check may use.
type Report ¶
type Report struct {
Schema string `json:"schema"`
Source string `json:"source"`
Generator string `json:"generator"`
Summary Summary `json:"summary"`
Findings []Finding `json:"findings"`
// reference and the check was not run offline: the report is then
// incomplete, and is never clean.
Unavailable bool `json:"unavailable"`
// Notes say what was not checked and why.
Notes []string `json:"notes,omitempty"`
}
Report is the outcome of checking one manuscript.
func (Report) Exit ¶
Exit is the exit code for the report at a --fail-on level: findings at or above it come first; then a check that could not ask about every reference is never clean.
type SourceTexts ¶
type SourceTexts struct {
// Dir holds local copies of cited works, named by arXiv id
// ("2306.05685.pdf"), DOI with "/" as "_" ("10.1145_363235.363259.pdf"),
// BibTeX key or list label ("12.pdf").
Dir string
// Extract reads a local file's text (internal/pdf.Extract).
Extract func(ctx context.Context, path string) (string, error)
// Download reads a full text at an address, or is nil when the check
// may not use the network.
Download func(ctx context.Context, url string) (string, error)
}
SourceTexts reads cited works: a local copy in Dir first, then the full text the work's record points at, then its abstract.
type Summary ¶
type Summary struct {
References int `json:"references"`
Cited int `json:"cited"`
Resolved int `json:"resolved"`
Unchecked int `json:"unchecked"`
Supported int `json:"supported"`
Errors int `json:"errors"`
Warnings int `json:"warnings"`
}
Summary counts what was checked.