priorwork 0.2.1__tar.gz → 0.2.2__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.
- {priorwork-0.2.1 → priorwork-0.2.2}/PKG-INFO +3 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/__init__.py +1 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/api.py +4 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/AGENTS.md +10 -7
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-check/SKILL.md +4 -2
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-derive/SKILL.md +1 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-extract/SKILL.md +11 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-new/SKILL.md +2 -2
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/env.example +3 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/AGENTS.md +10 -7
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-check/SKILL.md +4 -2
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-derive/SKILL.md +1 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-extract/SKILL.md +11 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-new/SKILL.md +2 -2
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/check.py +94 -11
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/cli.py +207 -13
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/derived.py +1 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/docs/reference.ja.md +33 -5
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/docs/reference.md +62 -5
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/doctor.py +23 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/fulltext.py +211 -6
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/lang_ja.py +83 -4
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/octavo.py +22 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/ssci.py +14 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/survey.py +85 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/worktree.py +10 -3
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork.egg-info/PKG-INFO +3 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork.egg-info/SOURCES.txt +2 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork.egg-info/requires.txt +3 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/pyproject.toml +3 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_check_citations.py +13 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_cli_json.py +2 -1
- priorwork-0.2.2/tests/test_fulltext_reading.py +161 -0
- priorwork-0.2.2/tests/test_survey_fugu.py +227 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_survey_notes.py +1 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_worktree.py +59 -1
- {priorwork-0.2.1 → priorwork-0.2.2}/LICENSE +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/README.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/__main__.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-audit/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-manuscript/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-screen/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/skills/priorwork-snowball/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/templates/literature_review.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/templates/manuscript.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/en/templates/medical_review.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-audit/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-manuscript/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-screen/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/skills/priorwork-snowball/SKILL.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/templates/literature_review.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/templates/manuscript.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/assets/ja/templates/medical_review.md +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/docsref.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/export.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/i18n.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/manuscript.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/requests.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/scaffold.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/settings.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/snowball.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/workspace.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork/zotero.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork.egg-info/dependency_links.txt +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork.egg-info/entry_points.txt +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/priorwork.egg-info/top_level.txt +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/setup.cfg +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_api.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_check_cards.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_check_depth.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_check_fulltext_cli.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_docs_commands.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_doctor.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_english.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_export.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_extension.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_i18n.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_journal_search.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_manuscript.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_manuscript_read.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_medical.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_octavo.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_requests_6.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_scaffold.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_search_zotero.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_settings.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_site.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_ssci.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_survey.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_survey_pay.py +0 -0
- {priorwork-0.2.1 → priorwork-0.2.2}/tests/test_zotero_sync.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: priorwork
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.2
|
|
4
4
|
Summary: Build literature reviews for the social sciences and clinical research in conversation with an AI agent (Semantic Scholar + OpenAlex + PubMed)
|
|
5
5
|
Author: yoshida-kd
|
|
6
6
|
License-Expression: MIT
|
|
@@ -24,6 +24,8 @@ Requires-Dist: pypdf>=4.0
|
|
|
24
24
|
Requires-Dist: markdown-it-py>=3.0
|
|
25
25
|
Provides-Extra: dev
|
|
26
26
|
Requires-Dist: pytest>=8; extra == "dev"
|
|
27
|
+
Provides-Extra: docling
|
|
28
|
+
Requires-Dist: docling>=2.40; extra == "docling"
|
|
27
29
|
Dynamic: license-file
|
|
28
30
|
|
|
29
31
|
# Priorwork
|
|
@@ -830,7 +830,10 @@ class LiteratureClient:
|
|
|
830
830
|
mark_retracted(r)
|
|
831
831
|
continue
|
|
832
832
|
added = []
|
|
833
|
-
if
|
|
833
|
+
if ssci.same_main_title(oa["title"], r["title"]):
|
|
834
|
+
if not ssci.same_title(oa["title"], r["title"]):
|
|
835
|
+
r["notes"].append(t("The DOI's title differs only in the subtitle: \"{title}\"", title=oa["title"]))
|
|
836
|
+
elif not ssci.same_title(oa["title"], r["title"]):
|
|
834
837
|
added.append(t("The DOI points to another title: \"{title}\" (verify the DOI)", title=oa["title"]))
|
|
835
838
|
r["warnings"].append(added[-1])
|
|
836
839
|
# Zotero 取り込み・SSCI 照合に使う書誌情報は、DOI の実体(OpenAlex)側で丸ごと置き換える
|
|
@@ -123,11 +123,12 @@ Audit only when the user asks for it. An audit is not a condition for a survey t
|
|
|
123
123
|
The workspace is kept in a private GitHub repository. You may operate Git without asking, up to opening a pull request (if `AGENTS.local.md` decides otherwise, follow it). **The user merges.**
|
|
124
124
|
|
|
125
125
|
- **The branch is named after the survey**, exactly as `./priorwork new` printed it (e.g. `20261015_statutory_text_analysis`; a redo is `20261015_v2_<slug>`). Do not make up branch names. For work not tied to a survey (editing `AGENTS.local.md`, say), ask the user for the branch name.
|
|
126
|
-
- **
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
126
|
+
- **Every survey has its own folder.** `./priorwork new` makes `worktrees/<slug>/` from the latest main (the remote's, if there is one), on a new branch named after the survey, and shares the keys, journal lists, Python and cache. The workspace folder stays on main and is never switched, so another session working there is not disturbed. Run everything for the survey from its folder (`cd worktrees/<slug>`), and commit, push and open the pull request there as below. Do not `git switch` in the workspace folder.
|
|
127
|
+
- A new survey: just `./priorwork new ...` from the workspace folder (no `git switch`, no `git pull`). If it says it made the survey in this folder instead (no Git, or no commit yet), run `git switch -c <survey name>` after it.
|
|
128
|
+
- Continuing or auditing: `./priorwork status` lists the worktrees; go to the survey's folder (`cd worktrees/<slug>`) and `git pull --ff-only` if its branch is on the remote. A survey made before this, on a branch and not in a folder, is continued as it was: `git switch <survey name>` only if the workspace folder has no uncommitted changes and no other session may be using it; otherwise ask.
|
|
129
|
+
- Look at `git status` in the survey's folder when you start. Uncommitted changes that are not this survey's: do not touch them; ask in your report.
|
|
130
|
+
- Remove a survey's folder (`./priorwork worktree --remove <slug>`; the branch stays) only when the user asks, after its pull request is merged.
|
|
131
|
+
- **Commit** at the end of each step (search, screening, cards, check, export, audit) and before you stop. Add only this survey's files (`git add 'reports/<survey name>.*' .priorwork/surveys/<survey name>.json`; quote the `reports/…*`, or the shell passes the gitignored `.html` too and git adds nothing: "paths are ignored"), never `git add -A`. Write a one-line message in the report's language (e.g. "Screen the candidates (42 included)").
|
|
131
132
|
- **Push** only the working branch (`git push -u origin <survey name>`). If there is no remote, do not push; say so in your report.
|
|
132
133
|
- **Pull request**: once the report is exported, `gh pr create --base main --head <survey name> --title "<topic>" --body "<summary of your report>"`. If one is already open, do not open another (pushing updates it). If `gh` is missing or not logged in, do not open one; say so in your report. Give the URL of the pull request in your report.
|
|
133
134
|
- **Never** merge (`git merge`, `gh pr merge`), commit or push to main, force-push, `git reset --hard`, `git rebase`, `git clean`, or delete branches. Never commit `.env` (API keys).
|
|
@@ -181,7 +182,7 @@ For clinical research, create the survey with `./priorwork new ... --discipline
|
|
|
181
182
|
- Every paper you mention in the text must be registered in `./priorwork`. Never write authors, years or DOIs from memory.
|
|
182
183
|
- Write on a card only what the abstract or full text says, and always update its evidence level (unchecked / abstract only / full text checked). **Set "full text checked" only when you fetched the paper's full text with `./priorwork fulltext` and read it.** A card written from the abstract is "abstract only".
|
|
183
184
|
- On a card checked against the full text, give the page (`(p. 12)`) for numbers, methods and main findings. If the full text has no page breaks, write "(page not checked)". `./priorwork check` gives a WARN for numbers not in the full text and pages not in the paper.
|
|
184
|
-
- Cite the year of the journal issue, not the year it came out online. `./priorwork add`
|
|
185
|
+
- Cite the year of the journal issue, not the year it came out online. `./priorwork add` and `include` change a paper with a volume to its issue's year, and `./priorwork check` names included papers whose year differs. Fix them all with `./priorwork fix <survey name> --issue-years` (no need for one `fix --year` each).
|
|
185
186
|
- Write the cards **in the language of the report** (keep terms in the original in brackets). Do not copy the English abstract into a report in another language.
|
|
186
187
|
- When the text cites the literature, make sure **the direction of the finding** (does / does not, rises / falls) matches the card's main findings.
|
|
187
188
|
- **Never mix what the literature found with the framework and hypotheses of this study (the user's).** Write the user's typology or hypotheses only in the section "Hypotheses and implications for this study", never as a consensus of the literature.
|
|
@@ -200,7 +201,7 @@ For clinical research, create the survey with `./priorwork new ... --discipline
|
|
|
200
201
|
|
|
201
202
|
```bash
|
|
202
203
|
./priorwork status [SURVEY] # the list / progress and next steps
|
|
203
|
-
./priorwork new "<topic>" --slug <slug> --by "<model>" [--discipline social|medical] [--
|
|
204
|
+
./priorwork new "<topic>" --slug <slug> --by "<model>" [--discipline social|medical] [--here] [--mode standard|auto|manual] [--depth quick|full] [--manuscript PATH] [--question ... --years ... --fields ... --inclusion ... --exclusion ... --languages ...]
|
|
204
205
|
./priorwork scope SURVEY [--question ...] [--mode standard|auto|manual] [--go-on] [--depth quick|full] [--search-field social|medical|all] [--manuscript PATH] [--by "<model>"]
|
|
205
206
|
./priorwork archive SURVEY [--undo] # hide it from the list (the files stay); list the archived with status --archived
|
|
206
207
|
./priorwork search "<English query>" [--into SURVEY] [--bulk] [--sort citations|relevance|recent|cpy] [--year 2010-2024] [--journal "<full journal name>" ...] [--ssci-only] [--field social|medical|all] [--source auto|pubmed|s2] [--limit N]
|
|
@@ -208,6 +209,8 @@ For clinical research, create the survey with `./priorwork new ... --discipline
|
|
|
208
209
|
./priorwork include SURVEY N... --reason "..." ./priorwork exclude SURVEY N... --reason "..." ./priorwork maybe SURVEY N... --reason "..." ./priorwork reset SURVEY N...
|
|
209
210
|
./priorwork add SURVEY <DOI>... [--candidate] ./priorwork add SURVEY --cited # register the papers the manuscript cites (the DOIs in its .bib)
|
|
210
211
|
./priorwork fix SURVEY N [--id <published DOI>] [--authors "A; B"] [--year Y] [--journal J] [--pages P] [--confirm "<what you checked>"]
|
|
212
|
+
./priorwork fix SURVEY N --confirm-warning "<part of the WARN>" --reason "<what you checked>"
|
|
213
|
+
./priorwork fix SURVEY --issue-years [--dry-run]
|
|
211
214
|
./priorwork snowball SURVEY [--direction both|references|citations] [--limit N] [--min-links N]
|
|
212
215
|
./priorwork fulltext SURVEY N [--pdf PATH]
|
|
213
216
|
./priorwork card SURVEY N [--set KEY=VALUE ...]
|
|
@@ -32,18 +32,20 @@ Follow the rules in [AGENTS.md](../../../AGENTS.md).
|
|
|
32
32
|
| The full text has far fewer pages than the journal pages | The full text is incomplete (perhaps the publisher's preview). Do not fill the card from it; ask in your report for the whole PDF in Zotero (set the level to abstract only) |
|
|
33
33
|
| Evidence level unchecked / empty fields | Fill them in as in `priorwork-extract` |
|
|
34
34
|
| Citations not chased (full) | Do it as in `priorwork-snowball` |
|
|
35
|
-
| A number on a card is not in the full text / a cited page is not in the paper | Compare with the full text (the text from `./priorwork fulltext`) and fix it; remove it if the paper does not say it. If only the form differs (units, rounding), write it as the paper does |
|
|
35
|
+
| A number on a card is not in the full text / a cited page is not in the paper | Compare with the full text (the text from `./priorwork fulltext`) and fix it; remove it if the paper does not say it. If only the form differs (units, rounding), write it as the paper does. If you checked and the card is right (the number is in a table the text extraction missed, say), record it with `./priorwork fix <survey> N --confirm-warning "<the number>" --reason "<what you checked>"`; `check` then stops showing it |
|
|
36
36
|
| "Full text checked" but no page / no full text fetched | Read the full text and add the pages. If you did not read it, lower the evidence level to "abstract only" |
|
|
37
37
|
| A card is not in the report's language | Rewrite it in that language (keep terms in the original in brackets) |
|
|
38
38
|
| A synthesis section cites no paper | Rewrite it from the included papers, citing them as Author (year). If it is this study's own view, move it to "Hypotheses and implications for this study" |
|
|
39
39
|
| The text gives a wrong number of included papers | Delete the sentence with the count (the appendix gives it) |
|
|
40
40
|
| Included papers not in Zotero | If Priorwork may write to Zotero (the next step is `zotero <survey> --add`), add them with `--add` as the mode says (full auto: just add; standard and manual: show `--dry-run` and add once the user agrees). Otherwise show the DOIs from `./priorwork zotero <survey> --dois` as they are in your report (also those whose full text you got) |
|
|
41
|
+
| The year differs from the journal issue's | `./priorwork fix <survey> --issue-years` (`--dry-run` first to see them) |
|
|
42
|
+
| The Octavo project is not found | If it moved or was split, link the new project(s) and unlink the old one as in `./priorwork docs octavo` |
|
|
41
43
|
| The survey and the Octavo project use different Zotero collections | Ask the user which one to use. The survey's is set with `./priorwork zotero <survey> --collection "<name>"`; the user sets Octavo's with `octavo config set zotero_collection "<name>"` |
|
|
42
44
|
| The draft cites papers not in the Octavo project's .bib | Give their DOIs in your report; the user puts them in the Zotero collection and runs `octavo bib pull`, then export again with `export --draft --octavo` |
|
|
43
45
|
| The Markdown does not match the state | `./priorwork render <survey>` |
|
|
44
46
|
| A managed block is missing | Restore the lost `<!-- BEGIN priorwork:… -->` / `<!-- END priorwork:… -->` from the git history or similar |
|
|
45
47
|
|
|
46
|
-
3. Repeat 1–2 until there are no ERRORs. Mention the WARNs and INFOs you could not fix in your report.
|
|
48
|
+
3. Repeat 1–2 until there are no ERRORs. Mention the WARNs and INFOs you could not fix in your report. Use `--confirm-warning` only for a WARN you checked against the source and found wrong, with the reason; never to make the count smaller.
|
|
47
49
|
|
|
48
50
|
**Never tell the user it is finished while ERRORs remain.**
|
|
49
51
|
|
|
@@ -55,4 +55,4 @@ Fix the ERRORs before exporting. For a WARN about a number, check the card again
|
|
|
55
55
|
|
|
56
56
|
## 4. Report
|
|
57
57
|
|
|
58
|
-
Say which file you wrote and what it is (purpose, length, structure), what you decided yourself, how many papers it cites, the WARNs left, and how to read it (AGENTS.md, "Showing the report"; the HTML is `reports/<survey>.<name>.html`). With Git, the file goes in with `git add reports/<survey
|
|
58
|
+
Say which file you wrote and what it is (purpose, length, structure), what you decided yourself, how many papers it cites, the WARNs left, and how to read it (AGENTS.md, "Showing the report"; the HTML is `reports/<survey>.<name>.html`). With Git, the file goes in with `git add 'reports/<survey>.*'`.
|
|
@@ -13,7 +13,7 @@ Follow the rules in [AGENTS.md](../../../AGENTS.md).
|
|
|
13
13
|
## By depth
|
|
14
14
|
|
|
15
15
|
- `full`: for **every included paper**, get the full text (`./priorwork fulltext`), fill in the card from it and set the evidence level to "full text checked". Do not pick papers to read by whether they are "core". "Abstract only" is allowed only for papers whose full text `fulltext` tried and could not find (the failure is recorded, and `check` tells it apart from not trying).
|
|
16
|
-
-
|
|
16
|
+
- Do not read the full text from start to end: it costs many tokens. Read it by parts, as in step 2: the outline, then the data and sample, the identification, the main results (tables) and the limitations.
|
|
17
17
|
- `quick`: filling in from the abstracts is fine (evidence level "abstract only").
|
|
18
18
|
|
|
19
19
|
Either way, write only what the abstract or full text says, and always update the evidence level. **Set "full text checked" only when you filled in the card from the full text you fetched with `./priorwork fulltext` and read.** A card written from the abstract is "abstract only", even if the full text is in the cache.
|
|
@@ -39,6 +39,16 @@ In a survey made from a manuscript (`priorwork-manuscript`), the papers the draf
|
|
|
39
39
|
|
|
40
40
|
If the source is "Zotero's index text (no page breaks)", do not give page numbers; write "(page not checked)".
|
|
41
41
|
|
|
42
|
+
**Read it by parts** rather than opening the whole file. The references are kept apart already.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
./priorwork fulltext <survey> <number> --outline # headings and table/figure captions, with pages
|
|
46
|
+
./priorwork fulltext <survey> <number> --pages 5-9 # the pages you need (data, method, results)
|
|
47
|
+
./priorwork fulltext <survey> <number> --grep "N =|sample|Table 3" # where a number or word appears
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Start from the outline and the abstract; read the pages for the data and sample, the identification, the main results and the limitations; use `--grep` to find a number or a table. Read further pages only when a field is still unclear. A paper read this way is still "full text checked": what counts is that the card comes from the full text, with pages. A text with no page breaks has no outline by page: use `--grep`, or read the file.
|
|
51
|
+
|
|
42
52
|
- If it says "The PDF has only N pages", the full text is incomplete (perhaps the publisher's preview). Do not fill the card from it; set it to abstract only, and ask in your report for the whole PDF in Zotero.
|
|
43
53
|
- Give pages as the journal prints them on each page of the PDF. For a text without journal pages (an author's accepted manuscript or a working-paper version), give the PDF page (the N of `=== page N ===`) and write in the memo "pages are those of the accepted-manuscript PDF".
|
|
44
54
|
|
|
@@ -25,10 +25,10 @@ Settle these from the request. For anything the request does not say, decide som
|
|
|
25
25
|
- The mode (`standard` / `auto` / `manual`): decide as in AGENTS.md, "Modes". If nothing says otherwise, `standard`.
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
./priorwork new "<topic (any language)>" --slug <slug> --by "<your model name>" --mode standard|auto|manual --depth quick|full --question "..." --years "..." --fields "..." --inclusion "..." --exclusion "..."
|
|
28
|
+
./priorwork new "<topic (any language)>" --slug <slug> --by "<your model name>" --mode standard|auto|manual --depth quick|full --question "..." --years "..." --fields "..." --inclusion "..." --exclusion "..." [--languages "..."]
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
`new` makes the survey in its own folder, `worktrees/<slug>/`, on a branch named after the survey; the workspace folder stays on main. From here on, run every command for the survey from that folder (`cd worktrees/<slug>`), as AGENTS.md, "Git" says. If it says it made the survey in this folder instead (no Git, or no commit yet), stay here and `git switch -c <survey name>`.
|
|
32
32
|
|
|
33
33
|
Give your own model name with `--by` (e.g. `"Gemini 3.1 Pro"`, `"Claude Opus 5.5"`).
|
|
34
34
|
|
|
@@ -43,3 +43,6 @@ ZOTERO_WEBDAV_PASSWORD=
|
|
|
43
43
|
# PRIORWORK_MAX_RETRIES=
|
|
44
44
|
# Cache lifetime in days (default: 7). Set PRIORWORK_NO_CACHE=1 to disable.
|
|
45
45
|
# PRIORWORK_CACHE_TTL_DAYS=
|
|
46
|
+
# How to read PDFs: auto (Docling if installed, else pypdf), docling or pypdf.
|
|
47
|
+
# Docling keeps tables and headings; install it with: pip install "priorwork[docling]"
|
|
48
|
+
# PRIORWORK_PDF_ENGINE=
|
|
@@ -123,11 +123,12 @@
|
|
|
123
123
|
ワークスペースは GitHub の非公開リポジトリに置く。エージェントは、ユーザーに聞かずに PR を作るところまで Git を操作してよい(`AGENTS.local.md` で別に決めていれば、そちらに従う)。**マージはユーザーがする。**
|
|
124
124
|
|
|
125
125
|
- **ブランチ名はサーベイ名そのもの**(`./priorwork new` が出した名前。例: `20261015_statutory_text_analysis`、やり直しなら `20261015_v2_<slug>`)。ブランチ名を自分で考えない。サーベイに結び付かない作業(`AGENTS.local.md` の直しなど)は、ブランチ名をユーザーに聞く。
|
|
126
|
-
-
|
|
127
|
-
-
|
|
128
|
-
-
|
|
129
|
-
-
|
|
130
|
-
-
|
|
126
|
+
- **サーベイごとに専用のフォルダで作業する。** `./priorwork new` は、最新の main(リモートがあればリモートのもの)から `worktrees/<slug>/` を、サーベイの名前の新しいブランチで作り、キー・雑誌のリスト・Python・キャッシュを共有する。ワークスペースのフォルダは main のまま置き、ブランチを切り替えないので、そこで動いている別のセッションを巻き込まない。そのサーベイのコマンドはすべてそのフォルダで実行し(`cd worktrees/<slug>`)、コミット・push・PR も下のとおりそこで行う。ワークスペースのフォルダで `git switch` しない。
|
|
127
|
+
- 新しいサーベイ: ワークスペースのフォルダで `./priorwork new ...` を実行するだけ(`git switch`・`git pull` は要らない)。「このフォルダに作りました」と出たら(Git が無い・まだコミットが無い)、そのあとに `git switch -c <サーベイ名>`。
|
|
128
|
+
- 続き・監査: `./priorwork status` が worktree を一覧する。そのサーベイのフォルダに移り(`cd worktrees/<slug>`)、ブランチがリモートにあれば `git pull --ff-only`。これより前にフォルダでなくブランチで作ったサーベイは、そのまま続ける: ワークスペースのフォルダに未コミットの変更が無く、別のセッションが使っていないと言えるときだけ `git switch <サーベイ名>`。そうでなければ聞く。
|
|
129
|
+
- 始めるときに、サーベイのフォルダで `git status` を見る。このサーベイのものでない未コミットの変更があれば、触らずに報告で聞く。
|
|
130
|
+
- サーベイのフォルダを消す(`./priorwork worktree --remove <slug>`。ブランチは残る)のは、PR のマージの後に、ユーザーに頼まれたときだけ。
|
|
131
|
+
- **コミット**: 工程の区切り(検索・選別・カード・検査・書き出し・監査)と、止まる前に。足すのはこのサーベイのファイルだけ(`git add 'reports/<サーベイ名>.*' .priorwork/surveys/<サーベイ名>.json`。`reports/…*` は引用符で囲む。囲まないとシェルが gitignore された `.html` まで渡し、git が「paths are ignored」で何も足さない)。`git add -A` は使わない。メッセージはレポートの言語で 1 行(例: 「候補の選別(採用 42 本)」)。
|
|
131
132
|
- **push**: 作業ブランチだけ(`git push -u origin <サーベイ名>`)。リモートが無ければ push せず、報告で伝える。
|
|
132
133
|
- **PR**: 書き出しまで済んだら `gh pr create --base main --head <サーベイ名> --title "<テーマ>" --body "<報告の要約>"`。PR が既にあれば作らない(push で更新される)。`gh` が無い・ログインしていなければ PR は作らず、報告で伝える。報告に PR の URL を書く。
|
|
133
134
|
- **しないこと**: マージ(`git merge`・`gh pr merge`)、main へのコミット・push、force push、`git reset --hard`・`git rebase`・`git clean`、ブランチの削除。`.env`(API キー)はコミットしない。
|
|
@@ -181,7 +182,7 @@ Zotero に書き込むのは、ユーザーが設定で許したとき(`.env`
|
|
|
181
182
|
- 文章中で論文に言及するときは、その論文が `./priorwork` に登録されていること。記憶だけで著者・年・DOI を書かない。
|
|
182
183
|
- カードには要旨・本文に書かれていることだけを書き、確認レベル(未確認 / 要旨のみ / 本文確認済)を必ず更新する。**「本文確認済」は、その論文の本文を `./priorwork fulltext` で取得して読んだときだけ**にする。要旨から書いたものは「要旨のみ」。
|
|
183
184
|
- 本文確認済のカードでは、数値・手法・主な結果にページ(`(p. 12)`)を添える。ページの分からない本文なら「(ページ未確認)」と書く。`./priorwork check` は、本文に無い数値・論文に無いページを WARN にする。
|
|
184
|
-
- 年は掲載号の年で引く(オンラインで先に公開された年ではない)。`./priorwork add` は巻のある論文の年を掲載号の年に直し、`./priorwork check`
|
|
185
|
+
- 年は掲載号の年で引く(オンラインで先に公開された年ではない)。`./priorwork add` と `include` は巻のある論文の年を掲載号の年に直し、`./priorwork check` は食い違う採用論文を知らせる。まとめて直すのは `./priorwork fix <サーベイ名> --issue-years`(1 本ずつの `fix --year` は要らない)。
|
|
185
186
|
- カードは**レポートの言語**で書く(日本語のレポートなら日本語。用語の原語は括弧内に残す)。要旨の英文をそのまま写さない。
|
|
186
187
|
- 文章で先行研究を引くときは、カードの「主な結果」と**結論の向き**(促す/促さない、増える/減る)が合っているか確かめる。
|
|
187
188
|
- **先行研究の知見と、本研究(ユーザー)の枠組み・仮説を混ぜない。** ユーザーが示した分類や仮説は「本研究の仮説と示唆」の節にだけ書き、先行研究の合意のように書かない。
|
|
@@ -200,7 +201,7 @@ Zotero に書き込むのは、ユーザーが設定で許したとき(`.env`
|
|
|
200
201
|
|
|
201
202
|
```bash
|
|
202
203
|
./priorwork status [SURVEY] # 一覧 / 進捗と次にやること
|
|
203
|
-
./priorwork new "<テーマ>" --slug <slug> --by "<モデル名>" [--discipline social|medical] [--
|
|
204
|
+
./priorwork new "<テーマ>" --slug <slug> --by "<モデル名>" [--discipline social|medical] [--here] [--mode standard|auto|manual] [--depth quick|full] [--manuscript PATH] [--question ... --years ... --fields ... --inclusion ... --exclusion ... --languages ...]
|
|
204
205
|
./priorwork scope SURVEY [--question ...] [--mode standard|auto|manual] [--go-on] [--depth quick|full] [--search-field social|medical|all] [--manuscript PATH] [--by "<モデル名>"]
|
|
205
206
|
./priorwork archive SURVEY [--undo] # 一覧から隠す(ファイルは残る)。アーカイブの一覧は status --archived
|
|
206
207
|
./priorwork search "<English query>" [--into SURVEY] [--bulk] [--sort citations|relevance|recent|cpy] [--year 2010-2024] [--journal "<full journal name>" ...] [--ssci-only] [--field social|medical|all] [--source auto|pubmed|s2] [--limit N]
|
|
@@ -208,6 +209,8 @@ Zotero に書き込むのは、ユーザーが設定で許したとき(`.env`
|
|
|
208
209
|
./priorwork include SURVEY N... --reason "..." ./priorwork exclude SURVEY N... --reason "..." ./priorwork maybe SURVEY N... --reason "..." ./priorwork reset SURVEY N...
|
|
209
210
|
./priorwork add SURVEY <DOI>... [--candidate] ./priorwork add SURVEY --cited # 原稿が引いている論文(.bib の DOI)を登録
|
|
210
211
|
./priorwork fix SURVEY N [--id <掲載版の DOI>] [--authors "A; B"] [--year Y] [--journal J] [--pages P] [--confirm "<確かめたこと>"]
|
|
212
|
+
./priorwork fix SURVEY N --confirm-warning "<WARN の文言の一部>" --reason "<確かめたこと>"
|
|
213
|
+
./priorwork fix SURVEY --issue-years [--dry-run]
|
|
211
214
|
./priorwork snowball SURVEY [--direction both|references|citations] [--limit N] [--min-links N]
|
|
212
215
|
./priorwork fulltext SURVEY N [--pdf PATH]
|
|
213
216
|
./priorwork card SURVEY N [--set KEY=VALUE ...]
|
|
@@ -32,18 +32,20 @@ description: >-
|
|
|
32
32
|
| 本文が掲載誌のページ数よりずっと少ない | 出版社のプレビューなどで本文が欠けている。その本文でカードを書かず、報告で「Zotero に PDF の全体を添付してほしい」と伝える(確認レベルは「要旨のみ」) |
|
|
33
33
|
| 確認レベルが未確認 / 未記入の欄 | `priorwork-extract` の手順で記入 |
|
|
34
34
|
| スナウボール未実施(full) | `priorwork-snowball` の手順で行う |
|
|
35
|
-
| カードの数値が本文に見つからない / 引くページが論文に無い | 本文(`./priorwork fulltext`
|
|
35
|
+
| カードの数値が本文に見つからない / 引くページが論文に無い | 本文(`./priorwork fulltext` のテキスト)と突き合わせて直す。本文に無ければ消す。表記の違い(単位・丸め)なら本文の表記に合わせる。確かめてカードが正しかった(本文のテキストが取りこぼした表にあるなど)なら、`./priorwork fix <survey> N --confirm-warning "<その数値>" --reason "<確かめたこと>"` で記録する。以後の `check` には出ない |
|
|
36
36
|
| 本文確認済なのにページが無い / 本文を取得した記録が無い | 本文を読んでページを添える。本文を読んでいなければ確認レベルを「要旨のみ」に下げる |
|
|
37
37
|
| カードがレポートの言語でない | レポートの言語で書き直す(用語の原語は括弧内に残す) |
|
|
38
38
|
| まとめの節が論文を引いていない | 採用論文に基づいて書き直し、著者 (年) で引く。本研究の考えなら「本研究の仮説と示唆」に移す |
|
|
39
39
|
| 本文の採用数が実際と違う | 本数を書いた文を消す(付録の記録にある) |
|
|
40
40
|
| Zotero にない採用論文 | Priorwork が書き込めれば(次にやることが `zotero <survey> --add`)、進め方に従って `--add` で入れる(全自動はそのまま、標準・手動は `--dry-run` を示して了解を得てから)。そうでなければ `./priorwork zotero <survey> --dois` の DOI をそのまま報告で示す(本文を取得できた論文も除かない) |
|
|
41
|
+
| 年が掲載号の年と違う | `./priorwork fix <survey> --issue-years`(先に `--dry-run` で一覧を見る) |
|
|
42
|
+
| Octavo のプロジェクトが見つからない | 移したり分けたりしたなら、`./priorwork docs octavo` の手順で新しいプロジェクトを結び付け、古いものを外す |
|
|
41
43
|
| サーベイと Octavo のプロジェクトで Zotero のコレクションが違う | どちらに合わせるかをユーザーに聞く。サーベイ側は `./priorwork zotero <survey> --collection "<名前>"`、Octavo 側はユーザーが `octavo config set zotero_collection "<名前>"` |
|
|
42
44
|
| 下書きが Octavo の .bib に無い論文を引いている | その DOI を報告で示し、Zotero のコレクションに入れて `octavo bib pull` してから `export --draft --octavo` し直すよう伝える |
|
|
43
45
|
| Markdown が状態ファイルと一致しない | `./priorwork render <survey>` |
|
|
44
46
|
| 管理ブロックが見つからない | 消えた `<!-- BEGIN priorwork:… -->` / `<!-- END priorwork:… -->` を git の履歴などから復元 |
|
|
45
47
|
|
|
46
|
-
3. ERROR が 0 になるまで 1〜2 を繰り返す。直せない WARN と INFO
|
|
48
|
+
3. ERROR が 0 になるまで 1〜2 を繰り返す。直せない WARN と INFO は、報告で伝える。`--confirm-warning` は、原典と突き合わせて誤りと分かった WARN にだけ、理由を付けて使う。件数を減らすために使わない。
|
|
47
49
|
|
|
48
50
|
**ERROR が残っている間は、ユーザーに「完成した」と言わない。**
|
|
49
51
|
|
|
@@ -55,4 +55,4 @@ ERROR を直してから書き出す。WARN の数値は、カードを本文と
|
|
|
55
55
|
|
|
56
56
|
## 4. 報告
|
|
57
57
|
|
|
58
|
-
どのファイルに何を書いたか(用途・字数・構成)、推測で決めた点、引いた論文の数、残った WARN、読む版の見方(AGENTS.md「レポートを見せる」。HTML は `reports/<survey>.<名前>.html`)を短く伝える。Git を使うなら、このファイルも `git add reports
|
|
58
|
+
どのファイルに何を書いたか(用途・字数・構成)、推測で決めた点、引いた論文の数、残った WARN、読む版の見方(AGENTS.md「レポートを見せる」。HTML は `reports/<survey>.<名前>.html`)を短く伝える。Git を使うなら、このファイルも `git add 'reports/<サーベイ名>.*'` に入る。
|
|
@@ -13,7 +13,7 @@ description: >-
|
|
|
13
13
|
## 深さによる違い
|
|
14
14
|
|
|
15
15
|
- `full`: **採用論文すべて**について本文を取得し(`./priorwork fulltext`)、本文から記入して確認レベルを「本文確認済」にする。「中核かどうか」で読む論文を選ばない。「要旨のみ」にしてよいのは、`fulltext` を試して本文が見つからなかった論文だけ(失敗は記録され、`check` が「試していない」と区別する)。
|
|
16
|
-
-
|
|
16
|
+
- 本文を頭から全部読まない(トークンを多く使う)。手順 2 のとおり部分ごとに読む: 目次 → データ・サンプル、識別戦略、主な結果(表)、限界。
|
|
17
17
|
- `quick`: 要旨だけで記入してよい(確認レベルは「要旨のみ」)。
|
|
18
18
|
|
|
19
19
|
どちらでも、要旨・本文に書かれていることだけを書き、確認レベルを必ず更新する。**「本文確認済」にするのは、`./priorwork fulltext` で取得した本文を読んで記入したときだけ。** 要旨から書いたカードは、本文がキャッシュにあっても「要旨のみ」にする。
|
|
@@ -39,6 +39,16 @@ description: >-
|
|
|
39
39
|
|
|
40
40
|
取得元が「Zotero の索引テキスト(ページ区切りなし)」の場合、ページ番号は書かず「(ページ未確認)」とする。
|
|
41
41
|
|
|
42
|
+
**ファイル全体を開かず、部分ごとに読む。** 参照文献はすでに別に分けてある。
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
./priorwork fulltext <survey> <番号> --outline # 見出しと表・図の見出し(ページ付き)
|
|
46
|
+
./priorwork fulltext <survey> <番号> --pages 5-9 # 必要なページ(データ・手法・結果)
|
|
47
|
+
./priorwork fulltext <survey> <番号> --grep "N =|sample|Table 3" # 数値や語の出てくる所
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
目次と要旨から始め、データ・サンプル、識別戦略、主な結果、限界のページを読み、数値や表は `--grep` で探す。ほかのページを読むのは、欄がまだ埋まらないときだけ。こう読んでも「本文確認済」でよい(大事なのは、カードが本文から、ページ付きで書かれていること)。ページ区切りの無い本文には、ページごとの目次が無い。`--grep` を使うか、ファイルを読む。
|
|
51
|
+
|
|
42
52
|
- 「PDF は N ページしかない」と出たら、出版社のプレビューなどで本文が欠けている。その本文でカードを書かず「要旨のみ」にし、報告で PDF の全体を Zotero に添付するよう頼む。
|
|
43
53
|
- ページは掲載誌のページ(PDF の各ページに印刷された番号)で書く。著者最終稿(AAM)・原稿版など掲載誌のページが無い本文では、PDF のページ(`=== page N ===` の N)で書き、メモに「ページは AAM の PDF のページ」と書く。
|
|
44
54
|
|
|
@@ -25,10 +25,10 @@ description: >-
|
|
|
25
25
|
- 進め方(`standard` / `auto` / `manual`): AGENTS.md「進め方」で決める。何も言われなければ `standard`。
|
|
26
26
|
|
|
27
27
|
```bash
|
|
28
|
-
./priorwork new "<テーマ(日本語可)>" --slug <slug> --by "<自分のモデル名>" --mode standard|auto|manual --depth quick|full --question "..." --years "..." --fields "..." --inclusion "..." --exclusion "..."
|
|
28
|
+
./priorwork new "<テーマ(日本語可)>" --slug <slug> --by "<自分のモデル名>" --mode standard|auto|manual --depth quick|full --question "..." --years "..." --fields "..." --inclusion "..." --exclusion "..." [--languages "..."]
|
|
29
29
|
```
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
`new` は、サーベイを専用のフォルダ `worktrees/<slug>/` に、サーベイの名前のブランチで作る。ワークスペースのフォルダは main のまま。ここから先、そのサーベイのコマンドはすべてそのフォルダで実行する(`cd worktrees/<slug>`。AGENTS.md「Git」)。「このフォルダに作りました」と出たら(Git が無い・まだコミットが無い)、ここで `git switch -c <サーベイ名>`。
|
|
32
32
|
|
|
33
33
|
`--by` には自分のモデル名(例: `"Gemini 3.1 Pro"`、`"Claude Opus 5.5"`)を書く。
|
|
34
34
|
|
|
@@ -13,7 +13,7 @@ from .i18n import t, tl
|
|
|
13
13
|
from .survey import (
|
|
14
14
|
CANDIDATE, EVIDENCE_ABSTRACT, EVIDENCE_FULLTEXT, EVIDENCE_KEYS, EVIDENCE_UNCHECKED, INCLUDED, MAYBE, Survey,
|
|
15
15
|
SurveyError,
|
|
16
|
-
HYPHENS, evidence_key, evidence_label, extract_blocks,
|
|
16
|
+
HYPHENS, ascii_fold, display_surname, evidence_key, evidence_label, extract_blocks, parse_card_fields, parse_cards, strip_blocks,
|
|
17
17
|
surname, year_labels,
|
|
18
18
|
)
|
|
19
19
|
|
|
@@ -22,7 +22,10 @@ ERROR, WARN, INFO = "ERROR", "WARN", "INFO"
|
|
|
22
22
|
# 本文中の著者年引用:
|
|
23
23
|
# 叙述型 "Acemoglu et al. (2001)", "Acemoglu, Johnson and Robinson (2001, 2005)", "Dell (2010a, p. 3)"
|
|
24
24
|
# 括弧型 "(Dell, 2010)", "(e.g., Dell 2010; Acemoglu et al., 2001a, 2005)"
|
|
25
|
-
|
|
25
|
+
# 姓の前置詞: 空白で続くもの("van der Gaag"・"Dal Bó")と、小文字で始まり "-" や "'" でつながるもの("ben-Aaron"・"d'Aspremont"・"al-Hassan")
|
|
26
|
+
_PARTICLE = r"(?:[Vv]an|[Vv]on|[Dd]e|[Dd]er|[Dd]en|[Dd]es|du|da|[Dd]i|le|[Ll]a|[Dd]el|[Dd]ella|[Dd]alla|[Dd]al|[Dd]os|das|dei|ten|ter|ben|bin|ibn)"
|
|
27
|
+
_NAME = (r"(?:(?:[A-Z][A-Za-z\-]*\s+){1,5}(?:Group|Groups|Collaborators|Collaboration|Consortium|Investigators|Committee|Team|Trialists|Network)\b"
|
|
28
|
+
rf"|(?:{_PARTICLE}\s+){{0,3}}(?:[a-z]{{1,4}}['\-])?[A-Z][A-Za-z'\-]+)")
|
|
26
29
|
_AUTHORS = rf"{_NAME}(?:\s+et\s+al\.?|(?:\s*,\s*{_NAME})*,?\s*(?:and|&)\s*{_NAME})?"
|
|
27
30
|
_YEAR = r"\d{4}[a-z]?"
|
|
28
31
|
_GAP = r"[\s\x00]" # _fold が日本語などを \x00 にする。「Acemoglu ら (2001)」の「ら」を読み飛ばす
|
|
@@ -113,12 +116,79 @@ def find_citations(text: str) -> List[Citation]:
|
|
|
113
116
|
return sorted(unique.values())
|
|
114
117
|
|
|
115
118
|
|
|
119
|
+
_JOINED_PREFIX_RE = re.compile(r"^[a-z]{1,4}['\-](?=[A-Z])")
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
def _surname_keys(author: str) -> List[str]:
|
|
123
|
+
"""照合に使う姓。"ben-Aaron" のように小文字の前置詞でつながる姓は、前置詞の無い形("aaron")でも引けるようにする
|
|
124
|
+
(データベースや本文で前置詞が落ちたり大文字になったりする)。"""
|
|
125
|
+
keys = [surname(author)]
|
|
126
|
+
words = display_surname(author).split()
|
|
127
|
+
if words and _JOINED_PREFIX_RE.match(ascii_fold(words[-1])):
|
|
128
|
+
keys.append(surname(_JOINED_PREFIX_RE.sub("", ascii_fold(words[-1]))))
|
|
129
|
+
return keys
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
def _not_known_hint(name: str, e: Dict[str, Any]) -> str:
|
|
133
|
+
return t(" — not a sign that it points to another paper. Check that `priorwork get {doi}` gives this paper, then "
|
|
134
|
+
"record it with `priorwork fix {name} {number} --confirm \"<reason>\"`",
|
|
135
|
+
doi=e["record"]["doi"], name=name, number=e["number"])
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
def _templates(english: str) -> List[re.Pattern]:
|
|
139
|
+
"""検索のときに記録した警告(その時の表示の言語で書いてある)を、英日のどちらでも読み返す。"""
|
|
140
|
+
from .lang_ja import MESSAGES
|
|
141
|
+
return [re.compile("^" + re.escape(x).replace(re.escape("{title}"), "(.+)") + "$")
|
|
142
|
+
for x in (english, MESSAGES.get(english, english))]
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
_ANOTHER_TITLE = _templates("The DOI points to another title: \"{title}\" (verify the DOI)")
|
|
146
|
+
_NOT_KNOWN = _templates("OpenAlex does not know the DOI (verify the DOI)")
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def _record_warning(w: str, r: Dict[str, Any], label: str, name: str) -> Finding:
|
|
150
|
+
"""論文の書誌の警告。副題だけの違いは INFO、OpenAlex が DOI を知らないだけなら WARN、ほかは ERROR。"""
|
|
151
|
+
for pattern in _ANOTHER_TITLE:
|
|
152
|
+
m = pattern.match(w)
|
|
153
|
+
if m and ssci.same_main_title(m.group(1), r.get("title") or ""):
|
|
154
|
+
return INFO, t("{label}: the DOI's title differs only in the subtitle: \"{title}\"", label=label,
|
|
155
|
+
title=m.group(1))
|
|
156
|
+
if any(p.match(w) for p in _NOT_KNOWN):
|
|
157
|
+
return WARN, f"{label}: ⚠️ {w}"
|
|
158
|
+
return ERROR, f"{label}: ⚠️ {w}"
|
|
159
|
+
|
|
160
|
+
|
|
116
161
|
def ignored_citations(md: str) -> Set[Tuple[str, int]]:
|
|
117
162
|
"""`<!-- priorwork:ignore-citation World Bank (2010) -->` で検査から外した引用。"""
|
|
118
163
|
return {(surname(m.group(1)), int(m.group(2))) for m in _IGNORE_RE.finditer(_fold(md))}
|
|
119
164
|
|
|
120
165
|
|
|
121
166
|
def check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
167
|
+
return _without_checked_warnings(survey, _check_survey(survey, client))
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
_LABEL_NUMBER_RE = re.compile(r"^#(\d+)\b")
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def _without_checked_warnings(survey: Survey, findings: List[Finding]) -> List[Finding]:
|
|
174
|
+
"""`fix --confirm-warning` で確かめたと記録した WARN を外し、外した数を INFO で伝える(ERROR は外さない)。"""
|
|
175
|
+
checked = {e["number"]: e["checked_warnings"] for e in survey.papers if e.get("checked_warnings")}
|
|
176
|
+
kept: List[Finding] = []
|
|
177
|
+
hidden: List[int] = []
|
|
178
|
+
for level, msg in findings:
|
|
179
|
+
m = _LABEL_NUMBER_RE.match(msg)
|
|
180
|
+
if level == WARN and m and any(c["match"] in msg for c in checked.get(int(m.group(1)), [])):
|
|
181
|
+
hidden.append(int(m.group(1)))
|
|
182
|
+
continue
|
|
183
|
+
kept.append((level, msg))
|
|
184
|
+
if hidden:
|
|
185
|
+
kept.append((INFO, t("{n|# warning was|# warnings were} checked by hand and recorded with the reason ({numbers}; "
|
|
186
|
+
"`priorwork fix SURVEY N --confirm-warning`)", n=len(hidden),
|
|
187
|
+
numbers=", ".join(f"#{n}" for n in sorted(set(hidden))))))
|
|
188
|
+
return kept
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
def _check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
122
192
|
findings: List[Finding] = []
|
|
123
193
|
md = survey.md_path.read_text(encoding="utf-8")
|
|
124
194
|
|
|
@@ -138,7 +208,7 @@ def check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
|
138
208
|
for e in included:
|
|
139
209
|
r, label = e["record"], f"#{e['number']} {e['record']['title'][:50]}"
|
|
140
210
|
for w in r.get("warnings", []):
|
|
141
|
-
findings.append((
|
|
211
|
+
findings.append(_record_warning(w, r, label, survey.name))
|
|
142
212
|
if r.get("warnings"):
|
|
143
213
|
findings.append((INFO, t("{label}: if you have checked the details and they are right, record why with "
|
|
144
214
|
"`priorwork fix {name} {number} --confirm \"<reason>\"` (a working-paper DOI: add "
|
|
@@ -175,9 +245,10 @@ def check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
|
175
245
|
for e in survey.papers:
|
|
176
246
|
r = e["record"]
|
|
177
247
|
for a in r.get("authors", []):
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
entries
|
|
248
|
+
for name in _surname_keys(a):
|
|
249
|
+
entries = registered.setdefault((name, r.get("year")), [])
|
|
250
|
+
if e not in entries:
|
|
251
|
+
entries.append(e)
|
|
181
252
|
labels = year_labels(included)
|
|
182
253
|
# カードの記入欄も対象にする(要旨の <details> は論文側の文章なので除く)
|
|
183
254
|
card_text = "\n".join(re.sub(r"<details>.*?</details>", "", body, flags=re.S) for body in cards.values())
|
|
@@ -205,7 +276,7 @@ def check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
|
205
276
|
statuses=", ".join(sorted({e["status"] for e in entries})))))
|
|
206
277
|
continue
|
|
207
278
|
# 筆頭著者と年が同じ採用論文が複数あると、参照文献では 2001a / 2001b で区別している
|
|
208
|
-
same = [e for e in adopted if
|
|
279
|
+
same = [e for e in adopted if e["record"].get("authors") and c.name in _surname_keys(e["record"]["authors"][0])]
|
|
209
280
|
suffixed = {labels[e["key"]][-1]: e for e in same if labels[e["key"]][-1:].isalpha()}
|
|
210
281
|
assigned = ", ".join(f"#{e['number']} = {labels[e['key']]}" for e in suffixed.values())
|
|
211
282
|
if c.suffix and c.suffix not in suffixed:
|
|
@@ -242,8 +313,13 @@ def check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
|
242
313
|
findings.append((ERROR, t("{label}: this paper has been retracted. Exclude it (if the survey is about "
|
|
243
314
|
"the retraction itself, say so in your report)", label=label)))
|
|
244
315
|
if not w:
|
|
245
|
-
|
|
246
|
-
|
|
316
|
+
# 知らないだけで、別の論文を指しているのではない(採用論文の DOI はデータベースから来ている)
|
|
317
|
+
findings.append((WARN, t("{label}: OpenAlex does not know the DOI {doi}", label=label,
|
|
318
|
+
doi=e["record"]["doi"]) + _not_known_hint(survey.name, e)))
|
|
319
|
+
elif ssci.same_main_title(w.get("title") or "", e["record"]["title"]):
|
|
320
|
+
if not ssci.same_title(w.get("title") or "", e["record"]["title"]):
|
|
321
|
+
findings.append((INFO, t("{label}: the DOI's title differs only in the subtitle: \"{title}\"",
|
|
322
|
+
label=label, title=w.get("title"))))
|
|
247
323
|
elif not ssci.same_title(w.get("title") or "", e["record"]["title"]):
|
|
248
324
|
findings.append((ERROR, t("{label}: the DOI points to another title: \"{title}\". If the DOI is right, "
|
|
249
325
|
"record why with `priorwork fix {name} {number} --confirm \"<reason>\"`",
|
|
@@ -258,15 +334,21 @@ def check_survey(survey: Survey, client: Optional[Any] = None) -> List[Finding]:
|
|
|
258
334
|
findings.append((WARN, t("The years of {n|# included paper|# included papers} could not be checked against "
|
|
259
335
|
"the journal issues (Crossref did not answer). Run `priorwork check` again later",
|
|
260
336
|
n=len(dated))))
|
|
337
|
+
mismatched = 0
|
|
261
338
|
for e in dated:
|
|
262
339
|
issue = years.get(e["record"]["doi"].lower())
|
|
263
340
|
if issue and issue != e["record"]["year"]:
|
|
341
|
+
mismatched += 1
|
|
264
342
|
findings.append((WARN, t("#{number} {title}: registered as {year}, but the journal issue (vol. {volume}) "
|
|
265
343
|
"is {issue} — {year} is probably when it came out online. Cite the issue's "
|
|
266
344
|
"year: `priorwork fix {name} {number} --year {issue}`",
|
|
267
345
|
number=e["number"], title=e["record"]["title"][:50],
|
|
268
346
|
year=e["record"]["year"], volume=e["record"]["volume"], issue=issue,
|
|
269
347
|
name=survey.name)))
|
|
348
|
+
if mismatched > 1:
|
|
349
|
+
findings.append((INFO, t("To set the years of all {n} to the journal issues at once: "
|
|
350
|
+
"`priorwork fix {name} --issue-years` (`--dry-run` shows them first)",
|
|
351
|
+
n=mismatched, name=survey.name)))
|
|
270
352
|
|
|
271
353
|
# 4b. カードの書き方: サーベイの言語・本文の根拠
|
|
272
354
|
findings += _check_cards(survey, included, cards)
|
|
@@ -547,8 +629,9 @@ def _check_one_octavo(survey: Survey, md: str, info: dict) -> List[Finding]:
|
|
|
547
629
|
findings: List[Finding] = []
|
|
548
630
|
project = info["name"]
|
|
549
631
|
if info.get("missing"):
|
|
550
|
-
return [(WARN, t("The Octavo project {path} is not found. If it moved, link
|
|
551
|
-
"`priorwork scope {name} --octavo <path>`
|
|
632
|
+
return [(WARN, t("The Octavo project {path} is not found. If it moved or was split, link the new "
|
|
633
|
+
"{n|project|projects} with `priorwork scope {name} --octavo <path>` and remove this link with "
|
|
634
|
+
"`priorwork scope {name} --unlink-octavo {path}`", path=info["root"], name=survey.name, n=2))]
|
|
552
635
|
theirs = info["zotero_collections"]
|
|
553
636
|
ours = survey.zotero_collection.get("name", "")
|
|
554
637
|
shown = ", ".join(f'"{c}"' for c in theirs)
|