bibguard 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bibguard-0.2.0/.claude/commands/bibguard.md +19 -0
- bibguard-0.2.0/.codex/skills/bibguard/SKILL.md +32 -0
- bibguard-0.2.0/.cursor/rules/bibguard.md +40 -0
- bibguard-0.2.0/.gitignore +13 -0
- bibguard-0.2.0/CHANGELOG.md +34 -0
- bibguard-0.2.0/CONTRIBUTORS.md +16 -0
- bibguard-0.2.0/LICENSE +191 -0
- bibguard-0.2.0/PKG-INFO +302 -0
- bibguard-0.2.0/README.md +263 -0
- bibguard-0.2.0/docs/index.html +411 -0
- bibguard-0.2.0/pyproject.toml +57 -0
- bibguard-0.2.0/src/bibguard/__init__.py +36 -0
- bibguard-0.2.0/src/bibguard/autofix.py +55 -0
- bibguard-0.2.0/src/bibguard/cli.py +155 -0
- bibguard-0.2.0/src/bibguard/core.py +261 -0
- bibguard-0.2.0/src/bibguard/duplicates.py +22 -0
- bibguard-0.2.0/src/bibguard/matching.py +226 -0
- bibguard-0.2.0/src/bibguard/parsers/__init__.py +5 -0
- bibguard-0.2.0/src/bibguard/parsers/bibtex.py +61 -0
- bibguard-0.2.0/src/bibguard/py.typed +0 -0
- bibguard-0.2.0/src/bibguard/report.py +117 -0
- bibguard-0.2.0/src/bibguard/sources/__init__.py +9 -0
- bibguard-0.2.0/src/bibguard/sources/_common.py +20 -0
- bibguard-0.2.0/src/bibguard/sources/arxiv.py +41 -0
- bibguard-0.2.0/src/bibguard/sources/crossref.py +53 -0
- bibguard-0.2.0/src/bibguard/sources/dblp.py +81 -0
- bibguard-0.2.0/src/bibguard/sources/openalex.py +82 -0
- bibguard-0.2.0/src/bibguard/sources/s2.py +69 -0
- bibguard-0.2.0/src/bibguard/tex_audit.py +70 -0
- bibguard-0.2.0/tests/bench_golden.py +93 -0
- bibguard-0.2.0/tests/golden_benchmark.bib +449 -0
- bibguard-0.2.0/tests/golden_labels.json +60 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
Run the bibguard citation verification tool on a .bib file.
|
|
2
|
+
|
|
3
|
+
Usage: /bibguard <bib-file> [--tex <tex-file>] [--fix]
|
|
4
|
+
|
|
5
|
+
Instructions:
|
|
6
|
+
1. Parse the user's arguments. The first argument is the .bib file path. Optional: --tex for cross-audit, --fix to generate auto-corrected .bib.
|
|
7
|
+
2. Run the verification:
|
|
8
|
+
```
|
|
9
|
+
bibguard <bib-file> [--tex <tex-file>] [--out /tmp/refcheck_report.md] [--fix /tmp/refcheck_fixed.bib]
|
|
10
|
+
```
|
|
11
|
+
If `bibguard` is not on PATH, use: `python -m bibguard.cli <bib-file> ...`
|
|
12
|
+
3. Read the output report and present results to the user.
|
|
13
|
+
4. For any WARN or FAIL entries:
|
|
14
|
+
- Summarize what went wrong (phantom DOI, author mismatch, not found, etc.)
|
|
15
|
+
- For phantom_doi / phantom_arxiv FAILs: these are likely hallucinated references. Search the web to find the correct reference or confirm it doesn't exist.
|
|
16
|
+
- For other WARNs: check if the reference needs correction (wrong year, venue mismatch, etc.)
|
|
17
|
+
5. If --fix was used, show the auto-fix diff.
|
|
18
|
+
|
|
19
|
+
$ARGUMENTS
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: bibguard
|
|
3
|
+
description: Run citation verification on a .bib file. Detects hallucinated references, phantom DOIs, author mismatches, and retracted papers. Use when user asks to check, verify, or validate references/citations in a paper.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bibguard: Citation Verification
|
|
7
|
+
|
|
8
|
+
Run the bibguard tool to verify references in a .bib file.
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```
|
|
13
|
+
bibguard <bib-file> [--tex <tex-file>] [--out report.md] [--fix fixed.bib] [--json]
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
If `bibguard` is not on PATH, use: `pip install bibguard && bibguard <bib-file>`
|
|
17
|
+
|
|
18
|
+
## Instructions
|
|
19
|
+
|
|
20
|
+
1. Parse the user's request. Identify the .bib file path and any optional flags.
|
|
21
|
+
2. Run verification: `bibguard <bib-file> --out /tmp/refcheck_report.md`
|
|
22
|
+
3. Read the output report and present results.
|
|
23
|
+
4. For FAIL entries:
|
|
24
|
+
- **phantom_doi / phantom_arxiv**: The identifier has valid format but doesn't resolve. This is the strongest hallucination signal. Search the web to find the correct reference.
|
|
25
|
+
- **verification (NO API MATCH)**: Not found in any database. May be hallucinated or have a very different title.
|
|
26
|
+
- **retraction**: Paper has been retracted.
|
|
27
|
+
5. For WARN entries: Check if venue/year/author mismatches need correction.
|
|
28
|
+
6. If `--fix` was used, show what was auto-corrected.
|
|
29
|
+
|
|
30
|
+
## Arguments
|
|
31
|
+
|
|
32
|
+
$ARGUMENTS
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
---
|
|
2
|
+
description: Citation verification for academic papers using bibguard
|
|
3
|
+
globs: ["*.bib", "*.tex"]
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# bibguard Integration
|
|
7
|
+
|
|
8
|
+
When the user asks to verify, check, or validate references in a .bib file, use the `bibguard` CLI tool.
|
|
9
|
+
|
|
10
|
+
## Setup
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
pip install bibguard
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Commands
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# Basic verification
|
|
20
|
+
bibguard references.bib
|
|
21
|
+
|
|
22
|
+
# With TeX cross-audit
|
|
23
|
+
bibguard references.bib --tex main.tex
|
|
24
|
+
|
|
25
|
+
# Save report + auto-fix
|
|
26
|
+
bibguard references.bib --out report.md --fix fixed.bib
|
|
27
|
+
|
|
28
|
+
# JSON output for programmatic use
|
|
29
|
+
bibguard references.bib --json --out report.json
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Interpreting Results
|
|
33
|
+
|
|
34
|
+
- **FAIL (phantom_doi/phantom_arxiv)**: Identifier looks valid but doesn't resolve. Strongest hallucination signal. Search the web to find the correct reference or confirm it's fabricated.
|
|
35
|
+
- **FAIL (NO API MATCH)**: Not found in any of 5 databases. Likely hallucinated or title differs significantly.
|
|
36
|
+
- **FAIL (retraction)**: Paper has been retracted.
|
|
37
|
+
- **WARN**: Metadata mismatch (venue, year, author count). Usually needs human review.
|
|
38
|
+
- **OK**: Verified against at least one source.
|
|
39
|
+
|
|
40
|
+
Exit code 1 means at least one FAIL was found.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.2.0] - 2026-03-24
|
|
4
|
+
|
|
5
|
+
### Changed
|
|
6
|
+
- Renamed from `ref-check` to `bibguard` (PyPI name conflict)
|
|
7
|
+
- Upgraded to Apache 2.0 license
|
|
8
|
+
- Improved CLI output: emoji status, timing, fail summary
|
|
9
|
+
- Improved Markdown report: grouped by severity, compact OK entries
|
|
10
|
+
- Modular package structure (sources/, parsers/)
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- 58-case golden benchmark (`tests/bench_golden.py`)
|
|
14
|
+
- GitHub Pages landing page
|
|
15
|
+
- AI assistant skills: Claude Code, OpenAI Codex, Cursor
|
|
16
|
+
- CONTRIBUTORS.md with detailed attribution
|
|
17
|
+
- CHANGELOG.md
|
|
18
|
+
- `py.typed` marker (PEP 561)
|
|
19
|
+
- `--json` output mode for CI pipelines
|
|
20
|
+
- Bilingual README (English + Chinese)
|
|
21
|
+
|
|
22
|
+
### Benchmark
|
|
23
|
+
- Hallucination recall: 100% (14/14)
|
|
24
|
+
- Chimera detection: 100% (5/5)
|
|
25
|
+
- Runtime: 95s for 58 entries
|
|
26
|
+
|
|
27
|
+
## [0.1.0] - 2026-03-24
|
|
28
|
+
|
|
29
|
+
Initial release (as `ref-check`, not published to PyPI).
|
|
30
|
+
|
|
31
|
+
- 5-source cascade: arXiv, Crossref, DBLP, Semantic Scholar, OpenAlex
|
|
32
|
+
- Phantom DOI/arXiv detection with kill-shot logic
|
|
33
|
+
- TeX cross-audit, duplicate detection, auto-fix
|
|
34
|
+
- CLI and Python API
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Contributors
|
|
2
|
+
|
|
3
|
+
## Geoffrey Wang ([@GeoffreyWang1117](https://github.com/GeoffreyWang1117))
|
|
4
|
+
- Project creator and lead developer
|
|
5
|
+
- System architecture: 5-source cascade verification design
|
|
6
|
+
- Core algorithms: phantom-ID detection, kill-shot logic, author-guard search
|
|
7
|
+
- Early implementation: BibTeX parsing, API query modules, field matching heuristics
|
|
8
|
+
- Benchmark design: golden test set curation (58 cases across 4 categories)
|
|
9
|
+
- Extracted from [IntegriRef](https://github.com/GeoffreyWang1117/IntegriRef) L0 layer
|
|
10
|
+
|
|
11
|
+
## Claude (Anthropic)
|
|
12
|
+
- Code optimization: modular refactoring from single-file to package structure
|
|
13
|
+
- Output formatting: CLI progress display, Markdown report generation
|
|
14
|
+
- Packaging: pyproject.toml, cross-platform skill definitions
|
|
15
|
+
- Documentation: README, benchmark analysis, contributor attribution
|
|
16
|
+
- Model: Claude Opus 4.6 (1M context)
|
bibguard-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to the Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by the Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding any notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
Copyright 2026 Geoffrey Wang
|
|
180
|
+
|
|
181
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
182
|
+
you may not use this file except in compliance with the License.
|
|
183
|
+
You may obtain a copy of the License at
|
|
184
|
+
|
|
185
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
186
|
+
|
|
187
|
+
Unless required by applicable law or agreed to in writing, software
|
|
188
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
189
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
190
|
+
See the License for the specific language governing permissions and
|
|
191
|
+
limitations under the License.
|
bibguard-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: bibguard
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Detect hallucinated and broken citations in academic papers
|
|
5
|
+
Project-URL: Homepage, https://geoffreywang1117.github.io/bibguard/
|
|
6
|
+
Project-URL: Repository, https://github.com/GeoffreyWang1117/bibguard
|
|
7
|
+
Project-URL: Issues, https://github.com/GeoffreyWang1117/bibguard/issues
|
|
8
|
+
Project-URL: Changelog, https://github.com/GeoffreyWang1117/bibguard/blob/main/CHANGELOG.md
|
|
9
|
+
Author-email: Geoffrey Wang <geoffreywang1117@gmail.com>
|
|
10
|
+
License-Expression: Apache-2.0
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Keywords: academic,bibguard,bibtex,citation,hallucination,integrity,latex,reference,scholarly,verification
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Science/Research
|
|
15
|
+
Classifier: License :: OSI Approved :: Apache Software License
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
22
|
+
Classifier: Topic :: Scientific/Engineering
|
|
23
|
+
Classifier: Topic :: Text Processing :: Markup :: LaTeX
|
|
24
|
+
Classifier: Typing :: Typed
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Requires-Dist: bibtexparser<2,>=1.4
|
|
27
|
+
Requires-Dist: requests>=2.28
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: pymupdf>=1.23; extra == 'all'
|
|
30
|
+
Requires-Dist: rapidfuzz>=3.0; extra == 'all'
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest-cov; extra == 'dev'
|
|
33
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
34
|
+
Provides-Extra: fast
|
|
35
|
+
Requires-Dist: rapidfuzz>=3.0; extra == 'fast'
|
|
36
|
+
Provides-Extra: pdf
|
|
37
|
+
Requires-Dist: pymupdf>=1.23; extra == 'pdf'
|
|
38
|
+
Description-Content-Type: text/markdown
|
|
39
|
+
|
|
40
|
+
# bibguard
|
|
41
|
+
|
|
42
|
+
[](https://pypi.org/project/bibguard/)
|
|
43
|
+
[](https://pypi.org/project/bibguard/)
|
|
44
|
+
[](LICENSE)
|
|
45
|
+
[]()
|
|
46
|
+
|
|
47
|
+
**Detect hallucinated and broken citations in academic papers.**
|
|
48
|
+
|
|
49
|
+
One command to verify every reference in your `.bib` file against five scholarly databases. Catches phantom DOIs, fabricated arXiv IDs, author mismatches, retracted papers, and AI-hallucinated citations.
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
pip install bibguard
|
|
53
|
+
bibguard paper.bib
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
[Landing Page](https://geoffreywang1117.github.io/bibguard/) | [PyPI](https://pypi.org/project/bibguard/) | [Changelog](CHANGELOG.md)
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## Why
|
|
61
|
+
|
|
62
|
+
Large language models hallucinate citations. Copy-paste errors corrupt metadata. Retracted papers slip through review. `bibguard` catches these problems **before** submission.
|
|
63
|
+
|
|
64
|
+
- **5 sources**: arXiv, Crossref, DBLP, Semantic Scholar, OpenAlex
|
|
65
|
+
- **Phantom ID detection**: Valid-format DOI/arXiv that doesn't resolve = hallucination signal
|
|
66
|
+
- **Kill-shot logic**: A phantom ID cannot be overridden by a similar search result
|
|
67
|
+
- **TeX cross-audit**: Find `\cite{key}` with no `.bib` entry, and orphan entries never cited
|
|
68
|
+
- **Duplicate detection**: Flag near-identical entries with different keys
|
|
69
|
+
- **Auto-fix**: Generate a corrected `.bib` with missing DOIs and eprint IDs filled in
|
|
70
|
+
- **Zero heavy dependencies**: Core requires only `requests` + `bibtexparser`
|
|
71
|
+
|
|
72
|
+
## Install
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install bibguard # minimal
|
|
76
|
+
pip install bibguard[fast] # + RapidFuzz for better title matching
|
|
77
|
+
pip install bibguard[all] # + RapidFuzz + PyMuPDF for PDF parsing
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Requires Python 3.9+.
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
### CLI
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Basic: verify all entries in a .bib file
|
|
88
|
+
bibguard references.bib
|
|
89
|
+
|
|
90
|
+
# With TeX cross-audit (finds phantom \cite and orphan entries)
|
|
91
|
+
bibguard references.bib --tex main.tex
|
|
92
|
+
|
|
93
|
+
# Save report + auto-fix
|
|
94
|
+
bibguard references.bib --tex main.tex --out report.md --fix fixed.bib
|
|
95
|
+
|
|
96
|
+
# JSON output (for CI pipelines)
|
|
97
|
+
bibguard references.bib --json --out report.json
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Python API
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from bibguard import verify_bib, verify_entry
|
|
104
|
+
|
|
105
|
+
# Verify entire .bib file
|
|
106
|
+
results, report = verify_bib("references.bib", tex_path="main.tex")
|
|
107
|
+
for r in results:
|
|
108
|
+
if r.overall != "OK":
|
|
109
|
+
print(f"{r.overall}: {r.key} -- {r.title}")
|
|
110
|
+
|
|
111
|
+
# Verify a single entry
|
|
112
|
+
from bibguard.parsers.bibtex import parse_bib
|
|
113
|
+
entries = parse_bib("references.bib")
|
|
114
|
+
result = verify_entry(entries[0])
|
|
115
|
+
print(result.overall, result.checks)
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Exit codes
|
|
119
|
+
|
|
120
|
+
| Code | Meaning |
|
|
121
|
+
|------|---------|
|
|
122
|
+
| 0 | All entries OK or WARN |
|
|
123
|
+
| 1 | At least one FAIL (hallucination, phantom ID, no match, or retraction) |
|
|
124
|
+
| 2 | Input error (file not found) |
|
|
125
|
+
|
|
126
|
+
Use in CI: `bibguard references.bib || echo "Citation issues found"`
|
|
127
|
+
|
|
128
|
+
## How it works
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
Input (.bib)
|
|
132
|
+
|
|
|
133
|
+
v
|
|
134
|
+
Parse entries (bibtexparser)
|
|
135
|
+
|
|
|
136
|
+
v
|
|
137
|
+
For each entry:
|
|
138
|
+
1. arXiv lookup (by arXiv ID) -- direct ID resolution
|
|
139
|
+
2. Crossref lookup (by DOI) -- direct ID resolution
|
|
140
|
+
3. Phantom ID detection -- valid format but doesn't resolve?
|
|
141
|
+
4. DBLP search (by title + author) -- with author disambiguation
|
|
142
|
+
5. Semantic Scholar search -- fallback + citation count
|
|
143
|
+
6. OpenAlex search -- fallback for non-CS / old papers
|
|
144
|
+
|
|
|
145
|
+
v
|
|
146
|
+
Post-processing:
|
|
147
|
+
- Source-aware status (confirmed source overrides noisy cross-checks)
|
|
148
|
+
- Kill-shot: phantom ID overrides search-confirmed status
|
|
149
|
+
- Suggested fixes (missing DOI, eprint)
|
|
150
|
+
|
|
|
151
|
+
v
|
|
152
|
+
Report (Markdown / JSON)
|
|
153
|
+
+ TeX cross-audit (phantom refs, orphan entries)
|
|
154
|
+
+ Duplicate detection
|
|
155
|
+
+ Auto-fixed .bib
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Benchmark
|
|
159
|
+
|
|
160
|
+
Tested on a 58-case golden test set (`tests/golden_benchmark.bib`). Reproduce with `python tests/bench_golden.py`.
|
|
161
|
+
|
|
162
|
+
| Category | Metric | Result |
|
|
163
|
+
|----------|--------|--------|
|
|
164
|
+
| **Hallucinated** (14 fabricated + 1 control) | Detected as FAIL | **14/14 (100%)** |
|
|
165
|
+
| | Detected as >= WARN | **15/15 (100%)** |
|
|
166
|
+
| **Chimera** (5 mixed-metadata) | Detected as >= WARN | **5/5 (100%)** |
|
|
167
|
+
| **Real papers** (10 legitimate) | Clean pass (OK) | 4/10 (40%) |
|
|
168
|
+
| | False positive (FAIL) | 1/10 (10%) |
|
|
169
|
+
| **Retracted** (28 retractions) | Any issue flagged | 19/28 (68%) |
|
|
170
|
+
| **Runtime** | 58 entries | **95s (~1.6s/entry)** |
|
|
171
|
+
|
|
172
|
+
**Notes:**
|
|
173
|
+
- The 1 false-positive FAIL is a 1962 book with no DOI — a known edge case for API-based verification.
|
|
174
|
+
- WARN on real papers are mostly venue/author-count mismatches — reviewable by humans.
|
|
175
|
+
- All 14 truly fabricated citations are caught at FAIL level.
|
|
176
|
+
|
|
177
|
+
For semantic NLI, citation graph analysis, and Bayesian risk scoring, see [IntegriRef](https://github.com/GeoffreyWang1117/IntegriRef).
|
|
178
|
+
|
|
179
|
+
## AI Coding Assistant Integration
|
|
180
|
+
|
|
181
|
+
bibguard ships with skill/rule definitions for major AI coding assistants. The AI runs verification, analyzes FAIL entries, and searches the web to find correct references.
|
|
182
|
+
|
|
183
|
+
### Claude Code
|
|
184
|
+
|
|
185
|
+
```bash
|
|
186
|
+
mkdir -p ~/.claude/commands
|
|
187
|
+
curl -o ~/.claude/commands/bibguard.md \
|
|
188
|
+
https://raw.githubusercontent.com/GeoffreyWang1117/bibguard/main/.claude/commands/bibguard.md
|
|
189
|
+
```
|
|
190
|
+
Then use `/bibguard paper.bib` in Claude Code.
|
|
191
|
+
|
|
192
|
+
### OpenAI Codex CLI
|
|
193
|
+
|
|
194
|
+
```bash
|
|
195
|
+
mkdir -p ~/.codex/skills/bibguard
|
|
196
|
+
curl -o ~/.codex/skills/bibguard/SKILL.md \
|
|
197
|
+
https://raw.githubusercontent.com/GeoffreyWang1117/bibguard/main/.codex/skills/bibguard/SKILL.md
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Cursor
|
|
201
|
+
|
|
202
|
+
```bash
|
|
203
|
+
mkdir -p .cursor/rules
|
|
204
|
+
curl -o .cursor/rules/bibguard.md \
|
|
205
|
+
https://raw.githubusercontent.com/GeoffreyWang1117/bibguard/main/.cursor/rules/bibguard.md
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### Any other assistant
|
|
209
|
+
|
|
210
|
+
bibguard is a standard CLI tool. Any AI assistant that can run shell commands can use it:
|
|
211
|
+
```
|
|
212
|
+
bibguard paper.bib --json --out report.json
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Optional dependencies
|
|
216
|
+
|
|
217
|
+
| Package | Purpose | Install |
|
|
218
|
+
|---------|---------|---------|
|
|
219
|
+
| `rapidfuzz` | Better title matching (token_set_ratio) | `pip install bibguard[fast]` |
|
|
220
|
+
| `pymupdf` | PDF reference extraction (no GROBID needed) | `pip install bibguard[pdf]` |
|
|
221
|
+
|
|
222
|
+
## API sources
|
|
223
|
+
|
|
224
|
+
| Source | Lookup method | Coverage |
|
|
225
|
+
|--------|--------------|----------|
|
|
226
|
+
| arXiv | ID resolution | CS, Physics, Math, ... |
|
|
227
|
+
| Crossref | DOI resolution | 150M+ records |
|
|
228
|
+
| DBLP | Title search | CS papers (gold standard) |
|
|
229
|
+
| Semantic Scholar | Title search | 200M+ papers |
|
|
230
|
+
| OpenAlex | Title search | 250M+ works (all disciplines) |
|
|
231
|
+
|
|
232
|
+
All queries respect rate limits. No API keys required.
|
|
233
|
+
|
|
234
|
+
## Contributing
|
|
235
|
+
|
|
236
|
+
Issues and PRs welcome. To run tests:
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
git clone https://github.com/GeoffreyWang1117/bibguard.git
|
|
240
|
+
cd bibguard
|
|
241
|
+
pip install -e ".[dev]"
|
|
242
|
+
pytest
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
## Related
|
|
246
|
+
|
|
247
|
+
- [IntegriRef](https://github.com/GeoffreyWang1117/IntegriRef) -- Full L0-L4 verification stack with semantic NLI (93.5% accuracy), citation graph analysis, and Bayesian risk scoring
|
|
248
|
+
- [Rebiber](https://github.com/yuchenlin/rebiber) -- Normalize BibTeX with DBLP/ACL Anthology
|
|
249
|
+
|
|
250
|
+
## Contributors
|
|
251
|
+
|
|
252
|
+
See [CONTRIBUTORS.md](CONTRIBUTORS.md) for detailed attribution.
|
|
253
|
+
|
|
254
|
+
- **Geoffrey Wang** — Architecture, core algorithms, phantom-ID detection, kill-shot logic, benchmark design
|
|
255
|
+
- **Claude (Anthropic)** — Modular refactoring, output formatting, packaging, documentation
|
|
256
|
+
|
|
257
|
+
## License
|
|
258
|
+
|
|
259
|
+
Apache License 2.0. See [LICENSE](LICENSE) for details.
|
|
260
|
+
|
|
261
|
+
---
|
|
262
|
+
|
|
263
|
+
<details>
|
|
264
|
+
<summary><strong>中文说明</strong></summary>
|
|
265
|
+
|
|
266
|
+
# bibguard — 学术论文引用幻觉检测工具
|
|
267
|
+
|
|
268
|
+
**一行命令,检测论文中的虚假引用。**
|
|
269
|
+
|
|
270
|
+
大语言模型会"幻觉"出格式正确但根本不存在的参考文献。bibguard 用 5 个学术数据库(arXiv、Crossref、DBLP、Semantic Scholar、OpenAlex)交叉验证你的 `.bib` 文件。
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
pip install bibguard
|
|
274
|
+
bibguard paper.bib
|
|
275
|
+
```
|
|
276
|
+
|
|
277
|
+
### 核心能力
|
|
278
|
+
|
|
279
|
+
- **幽灵 DOI / arXiv ID 检测** — 格式正确但不存在 = 最强幻觉信号
|
|
280
|
+
- **Kill-shot 逻辑** — 幽灵 ID 不会被相似论文的搜索结果覆盖
|
|
281
|
+
- **TeX 交叉审计** — 检测 `\cite{key}` 在 `.bib` 中无定义,以及定义了但从未引用的条目
|
|
282
|
+
- **自动修复** — 补全缺失的 DOI 和 eprint 字段
|
|
283
|
+
- **极轻依赖** — 仅需 `requests` + `bibtexparser`
|
|
284
|
+
|
|
285
|
+
### 基准测试 (58 条公开测试集)
|
|
286
|
+
|
|
287
|
+
| 类别 | 指标 | 结果 |
|
|
288
|
+
|------|------|------|
|
|
289
|
+
| AI 幻觉引用 (14 条) | 检出率 (FAIL) | **100%** |
|
|
290
|
+
| 元数据嵌合体 (5 条) | 检出率 (>=WARN) | **100%** |
|
|
291
|
+
| 真实论文 (10 条) | 假阳率 (FAIL) | 10% (1 本 1962 年书籍) |
|
|
292
|
+
| 运行时间 | 58 条 | 95 秒 |
|
|
293
|
+
|
|
294
|
+
### AI 编程助手集成
|
|
295
|
+
|
|
296
|
+
支持 Claude Code (`/bibguard`)、OpenAI Codex、Cursor 自动触发。
|
|
297
|
+
|
|
298
|
+
### 深度验证
|
|
299
|
+
|
|
300
|
+
bibguard 是 L0(存在性验证)层。如需语义 NLI 验证 (93.5%)、引文图谱异常检测、贝叶斯风险评分,请使用 [IntegriRef](https://github.com/GeoffreyWang1117/IntegriRef)。
|
|
301
|
+
|
|
302
|
+
</details>
|