scitheory 0.0.1__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.
- scitheory-0.0.1/.github/workflows/ci.yml +26 -0
- scitheory-0.0.1/.gitignore +16 -0
- scitheory-0.0.1/CHANGELOG.md +7 -0
- scitheory-0.0.1/CITATION.cff +12 -0
- scitheory-0.0.1/LICENSE +21 -0
- scitheory-0.0.1/PKG-INFO +93 -0
- scitheory-0.0.1/README.md +63 -0
- scitheory-0.0.1/docs/index.md +10 -0
- scitheory-0.0.1/docs/schema.md +26 -0
- scitheory-0.0.1/examples/claims_synthetic.json +47 -0
- scitheory-0.0.1/mkdocs.yml +8 -0
- scitheory-0.0.1/pyproject.toml +48 -0
- scitheory-0.0.1/src/scitheory/__init__.py +35 -0
- scitheory-0.0.1/src/scitheory/explain/__init__.py +1 -0
- scitheory-0.0.1/src/scitheory/extract/__init__.py +1 -0
- scitheory-0.0.1/src/scitheory/gaps/__init__.py +1 -0
- scitheory-0.0.1/src/scitheory/graph/__init__.py +1 -0
- scitheory-0.0.1/src/scitheory/ingest/__init__.py +1 -0
- scitheory-0.0.1/src/scitheory/normalize/__init__.py +1 -0
- scitheory-0.0.1/src/scitheory/schema.py +171 -0
- scitheory-0.0.1/tests/test_package.py +14 -0
- scitheory-0.0.1/tests/test_schema.py +52 -0
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
strategy:
|
|
12
|
+
fail-fast: false
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12", "3.13"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
cache: pip
|
|
21
|
+
- name: Install
|
|
22
|
+
run: python -m pip install -e ".[dev]"
|
|
23
|
+
- name: Lint
|
|
24
|
+
run: ruff check .
|
|
25
|
+
- name: Test
|
|
26
|
+
run: pytest --cov=scitheory --cov-report=term-missing
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
cff-version: 1.2.0
|
|
2
|
+
message: "If you use this software, please cite it as below."
|
|
3
|
+
title: "SciTheory"
|
|
4
|
+
type: software
|
|
5
|
+
version: 0.0.1
|
|
6
|
+
date-released: 2026-10-07
|
|
7
|
+
license: MIT
|
|
8
|
+
repository-code: "https://github.com/MarcoFerreiraRibeiro/scitheory"
|
|
9
|
+
authors:
|
|
10
|
+
- family-names: "Ferreira Ribeiro"
|
|
11
|
+
given-names: "Marco"
|
|
12
|
+
abstract: "Claim graphs from the scientific literature to explain contradictions between studies and rank research gaps."
|
scitheory-0.0.1/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Marco Ferreira Ribeiro
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
scitheory-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: scitheory
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Claim graphs from the scientific literature: explain contradictions between studies and rank research gaps.
|
|
5
|
+
Project-URL: Homepage, https://github.com/MarcoFerreiraRibeiro/scitheory
|
|
6
|
+
Project-URL: Issues, https://github.com/MarcoFerreiraRibeiro/scitheory/issues
|
|
7
|
+
Author: Marco Ferreira Ribeiro
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: bibliometrics,knowledge graph,literature synthesis,research gaps,scientometrics
|
|
11
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: pydantic>=2.5
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest-cov>=5; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
25
|
+
Requires-Dist: ruff>=0.5; extra == 'dev'
|
|
26
|
+
Provides-Extra: docs
|
|
27
|
+
Requires-Dist: mkdocs-material>=9.5; extra == 'docs'
|
|
28
|
+
Requires-Dist: mkdocs>=1.6; extra == 'docs'
|
|
29
|
+
Description-Content-Type: text/markdown
|
|
30
|
+
|
|
31
|
+
# SciTheory
|
|
32
|
+
|
|
33
|
+
SciTheory turns empirical claims from scientific papers into a graph that keeps the context and
|
|
34
|
+
method of every claim. On that graph it does two things:
|
|
35
|
+
|
|
36
|
+
1. **Explains contradictions.** When studies disagree about the same relation, it tests whether
|
|
37
|
+
context (country, period, sample) or method (design, estimator) accounts for the difference.
|
|
38
|
+
2. **Ranks research gaps.** It orders open questions by the expected value of new evidence, and
|
|
39
|
+
separates "nobody has studied this" from "studying this would change what we know".
|
|
40
|
+
|
|
41
|
+
**Input scope: abstracts only.** SciTheory runs on titles and abstracts (from OpenAlex and similar
|
|
42
|
+
sources), not on full-text articles. This keeps it usable at corpus scale and independent of
|
|
43
|
+
publisher access, at the cost of less detail per paper: method and context fields are often
|
|
44
|
+
missing and stay optional in the schema.
|
|
45
|
+
|
|
46
|
+
> **Status: pre-alpha (0.0.1).** Only the claim schema exists so far. The modules for ingestion,
|
|
47
|
+
> extraction, normalisation, the graph, explanation and gaps are being built in the order set by
|
|
48
|
+
> the project plan.
|
|
49
|
+
|
|
50
|
+
## Install
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git clone https://github.com/MarcoFerreiraRibeiro/scitheory.git
|
|
54
|
+
cd scitheory
|
|
55
|
+
python -m pip install -e ".[dev]"
|
|
56
|
+
pytest
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
Python 3.10 or later.
|
|
60
|
+
|
|
61
|
+
## Claim schema (v0.1)
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
import json
|
|
65
|
+
from scitheory import Claim
|
|
66
|
+
|
|
67
|
+
claim = Claim.model_validate(json.load(open("examples/claims_synthetic.json"))[0])
|
|
68
|
+
print(claim.relation.direction, claim.context.country)
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
The fields are described in [docs/schema.md](docs/schema.md). The examples in `examples/` are
|
|
72
|
+
synthetic and do not come from real papers.
|
|
73
|
+
|
|
74
|
+
## Layout
|
|
75
|
+
|
|
76
|
+
| Module | Purpose | Work package |
|
|
77
|
+
| --- | --- | --- |
|
|
78
|
+
| `scitheory.ingest` | Metadata and abstracts, with provenance | WP02 |
|
|
79
|
+
| `scitheory.extract` | Claim extraction | WP03 |
|
|
80
|
+
| `scitheory.normalize` | Merging equivalent constructs | WP04 |
|
|
81
|
+
| `scitheory.graph` | Aggregated claim graph | WP05 |
|
|
82
|
+
| `scitheory.explain` | Contradiction explanation | WP06 |
|
|
83
|
+
| `scitheory.gaps` | Gap ranking | WP07 |
|
|
84
|
+
|
|
85
|
+
## Related work
|
|
86
|
+
|
|
87
|
+
SciClaim (per-sentence claim graphs), THEORIZER (theory generation from literature), PaperQA2
|
|
88
|
+
(contradiction detection) and metaBUS (curated findings) cover parts of this space. SciTheory's
|
|
89
|
+
focus is explaining why studies diverge and valuing what is still unknown.
|
|
90
|
+
|
|
91
|
+
## Licence and citation
|
|
92
|
+
|
|
93
|
+
MIT. See [LICENSE](LICENSE). To cite, use [CITATION.cff](CITATION.cff).
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# SciTheory
|
|
2
|
+
|
|
3
|
+
SciTheory turns empirical claims from scientific papers into a graph that keeps the context and
|
|
4
|
+
method of every claim. On that graph it does two things:
|
|
5
|
+
|
|
6
|
+
1. **Explains contradictions.** When studies disagree about the same relation, it tests whether
|
|
7
|
+
context (country, period, sample) or method (design, estimator) accounts for the difference.
|
|
8
|
+
2. **Ranks research gaps.** It orders open questions by the expected value of new evidence, and
|
|
9
|
+
separates "nobody has studied this" from "studying this would change what we know".
|
|
10
|
+
|
|
11
|
+
**Input scope: abstracts only.** SciTheory runs on titles and abstracts (from OpenAlex and similar
|
|
12
|
+
sources), not on full-text articles. This keeps it usable at corpus scale and independent of
|
|
13
|
+
publisher access, at the cost of less detail per paper: method and context fields are often
|
|
14
|
+
missing and stay optional in the schema.
|
|
15
|
+
|
|
16
|
+
> **Status: pre-alpha (0.0.1).** Only the claim schema exists so far. The modules for ingestion,
|
|
17
|
+
> extraction, normalisation, the graph, explanation and gaps are being built in the order set by
|
|
18
|
+
> the project plan.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git clone https://github.com/MarcoFerreiraRibeiro/scitheory.git
|
|
24
|
+
cd scitheory
|
|
25
|
+
python -m pip install -e ".[dev]"
|
|
26
|
+
pytest
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Python 3.10 or later.
|
|
30
|
+
|
|
31
|
+
## Claim schema (v0.1)
|
|
32
|
+
|
|
33
|
+
```python
|
|
34
|
+
import json
|
|
35
|
+
from scitheory import Claim
|
|
36
|
+
|
|
37
|
+
claim = Claim.model_validate(json.load(open("examples/claims_synthetic.json"))[0])
|
|
38
|
+
print(claim.relation.direction, claim.context.country)
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
The fields are described in [docs/schema.md](docs/schema.md). The examples in `examples/` are
|
|
42
|
+
synthetic and do not come from real papers.
|
|
43
|
+
|
|
44
|
+
## Layout
|
|
45
|
+
|
|
46
|
+
| Module | Purpose | Work package |
|
|
47
|
+
| --- | --- | --- |
|
|
48
|
+
| `scitheory.ingest` | Metadata and abstracts, with provenance | WP02 |
|
|
49
|
+
| `scitheory.extract` | Claim extraction | WP03 |
|
|
50
|
+
| `scitheory.normalize` | Merging equivalent constructs | WP04 |
|
|
51
|
+
| `scitheory.graph` | Aggregated claim graph | WP05 |
|
|
52
|
+
| `scitheory.explain` | Contradiction explanation | WP06 |
|
|
53
|
+
| `scitheory.gaps` | Gap ranking | WP07 |
|
|
54
|
+
|
|
55
|
+
## Related work
|
|
56
|
+
|
|
57
|
+
SciClaim (per-sentence claim graphs), THEORIZER (theory generation from literature), PaperQA2
|
|
58
|
+
(contradiction detection) and metaBUS (curated findings) cover parts of this space. SciTheory's
|
|
59
|
+
focus is explaining why studies diverge and valuing what is still unknown.
|
|
60
|
+
|
|
61
|
+
## Licence and citation
|
|
62
|
+
|
|
63
|
+
MIT. See [LICENSE](LICENSE). To cite, use [CITATION.cff](CITATION.cff).
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# SciTheory
|
|
2
|
+
|
|
3
|
+
SciTheory turns empirical claims from scientific papers into a graph that keeps the context and
|
|
4
|
+
method of every claim. It explains why studies disagree and ranks research gaps by the expected
|
|
5
|
+
value of new evidence.
|
|
6
|
+
|
|
7
|
+
Input scope: titles and abstracts only, not full-text articles. Method and context fields are
|
|
8
|
+
therefore often missing and are optional in the schema.
|
|
9
|
+
|
|
10
|
+
Status: pre-alpha. See the [claim schema](schema.md).
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Claim schema (v0.1)
|
|
2
|
+
|
|
3
|
+
A claim is one empirical statement from a paper. It is stored with the context and method needed
|
|
4
|
+
to explain why another study may disagree.
|
|
5
|
+
|
|
6
|
+
| Field | Meaning |
|
|
7
|
+
| --- | --- |
|
|
8
|
+
| `id` | Unique identifier of the claim. |
|
|
9
|
+
| `source` | Paper: DOI, OpenAlex id, title, year. |
|
|
10
|
+
| `sentence` | The sentence the claim was taken from, verbatim. |
|
|
11
|
+
| `section` | Where it appears. SciTheory runs on abstracts only, so this is `abstract` for records it produces; other values are allowed for hand-annotated records. |
|
|
12
|
+
| `variables` | At least two variables, each with a role: independent, dependent, moderator, mediator or control. |
|
|
13
|
+
| `relation` | Direction (positive, negative, null, mixed, non-monotonic), kind (causal, associative, predictive, comparative) and whether the paper reports its hypothesis as supported. |
|
|
14
|
+
| `effect` | Optional: measure, value, confidence interval, p-value, n. |
|
|
15
|
+
| `context` | Population, country, period, industry, level of analysis, sample size. |
|
|
16
|
+
| `method` | Design, estimator, data source. |
|
|
17
|
+
| `provenance` | Who or what produced the record: extractor, model, version, run id, confidence. |
|
|
18
|
+
|
|
19
|
+
Because only abstracts are read, `context` and `method` are frequently empty. Missing is stored as missing, never guessed.
|
|
20
|
+
|
|
21
|
+
A claim must have at least one independent and one dependent variable. Unknown fields are
|
|
22
|
+
rejected, so typos fail early.
|
|
23
|
+
|
|
24
|
+
The file `examples/claims_synthetic.json` holds three synthetic claims that disagree about the same
|
|
25
|
+
relation (board size and return on assets) in different contexts. They are illustrations and do
|
|
26
|
+
not come from real papers.
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"id": "example-001",
|
|
4
|
+
"source": {"doi": null, "title": "SYNTHETIC EXAMPLE, not a real paper", "year": 2020},
|
|
5
|
+
"sentence": "Firms with larger boards show lower return on assets in our sample.",
|
|
6
|
+
"section": "results",
|
|
7
|
+
"variables": [
|
|
8
|
+
{"name": "board size", "role": "independent"},
|
|
9
|
+
{"name": "return on assets", "role": "dependent"}
|
|
10
|
+
],
|
|
11
|
+
"relation": {"direction": "negative", "kind": "associative", "supported": true},
|
|
12
|
+
"effect": {"measure": "beta", "value": -0.12, "p_value": 0.03, "n": 410},
|
|
13
|
+
"context": {"population": "listed firms", "country": "Portugal", "period": "2008-2018", "level": "firm", "sample_size": 410},
|
|
14
|
+
"method": {"design": "panel", "estimator": "fixed effects", "data_source": "annual reports"},
|
|
15
|
+
"provenance": {"extractor": "synthetic-example"}
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "example-002",
|
|
19
|
+
"source": {"doi": null, "title": "SYNTHETIC EXAMPLE, not a real paper", "year": 2021},
|
|
20
|
+
"sentence": "Board size has no significant association with return on assets.",
|
|
21
|
+
"section": "results",
|
|
22
|
+
"variables": [
|
|
23
|
+
{"name": "board size", "role": "independent"},
|
|
24
|
+
{"name": "ROA", "role": "dependent"}
|
|
25
|
+
],
|
|
26
|
+
"relation": {"direction": "null", "kind": "associative", "supported": false},
|
|
27
|
+
"effect": {"measure": "beta", "value": 0.01, "p_value": 0.71, "n": 1200},
|
|
28
|
+
"context": {"population": "listed firms", "country": "United States", "period": "2000-2015", "level": "firm", "sample_size": 1200},
|
|
29
|
+
"method": {"design": "panel", "estimator": "OLS", "data_source": "Compustat"},
|
|
30
|
+
"provenance": {"extractor": "synthetic-example"}
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "example-003",
|
|
34
|
+
"source": {"doi": null, "title": "SYNTHETIC EXAMPLE, not a real paper", "year": 2022},
|
|
35
|
+
"sentence": "Board size is positively related to ROA, but only in firms with concentrated ownership.",
|
|
36
|
+
"section": "results",
|
|
37
|
+
"variables": [
|
|
38
|
+
{"name": "board size", "role": "independent"},
|
|
39
|
+
{"name": "ROA", "role": "dependent"},
|
|
40
|
+
{"name": "ownership concentration", "role": "moderator"}
|
|
41
|
+
],
|
|
42
|
+
"relation": {"direction": "positive", "kind": "associative", "supported": true},
|
|
43
|
+
"context": {"population": "listed firms", "country": "Spain", "period": "2010-2019", "level": "firm"},
|
|
44
|
+
"method": {"design": "panel", "estimator": "GMM"},
|
|
45
|
+
"provenance": {"extractor": "synthetic-example"}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.21"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "scitheory"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "Claim graphs from the scientific literature: explain contradictions between studies and rank research gaps."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = { text = "MIT" }
|
|
11
|
+
requires-python = ">=3.10"
|
|
12
|
+
authors = [{ name = "Marco Ferreira Ribeiro" }]
|
|
13
|
+
keywords = ["bibliometrics", "scientometrics", "literature synthesis", "knowledge graph", "research gaps"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
16
|
+
"Intended Audience :: Science/Research",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Programming Language :: Python :: 3.13",
|
|
23
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
24
|
+
]
|
|
25
|
+
dependencies = ["pydantic>=2.5"]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
dev = ["pytest>=8", "pytest-cov>=5", "ruff>=0.5"]
|
|
29
|
+
docs = ["mkdocs>=1.6", "mkdocs-material>=9.5"]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://github.com/MarcoFerreiraRibeiro/scitheory"
|
|
33
|
+
Issues = "https://github.com/MarcoFerreiraRibeiro/scitheory/issues"
|
|
34
|
+
|
|
35
|
+
[tool.hatch.build.targets.wheel]
|
|
36
|
+
packages = ["src/scitheory"]
|
|
37
|
+
|
|
38
|
+
[tool.pytest.ini_options]
|
|
39
|
+
testpaths = ["tests"]
|
|
40
|
+
addopts = "-q"
|
|
41
|
+
|
|
42
|
+
[tool.ruff]
|
|
43
|
+
line-length = 100
|
|
44
|
+
target-version = "py310"
|
|
45
|
+
src = ["src", "tests"]
|
|
46
|
+
|
|
47
|
+
[tool.ruff.lint]
|
|
48
|
+
select = ["E", "F", "I", "UP", "B"]
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"""SciTheory: claim graphs from the scientific literature.
|
|
2
|
+
|
|
3
|
+
The package turns empirical claims extracted from papers into a graph with
|
|
4
|
+
context and method attached to every claim. On that graph it explains why
|
|
5
|
+
studies diverge and ranks research gaps by expected value of information.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from scitheory.schema import (
|
|
9
|
+
Claim,
|
|
10
|
+
Context,
|
|
11
|
+
Direction,
|
|
12
|
+
Effect,
|
|
13
|
+
Method,
|
|
14
|
+
Provenance,
|
|
15
|
+
Relation,
|
|
16
|
+
Role,
|
|
17
|
+
Source,
|
|
18
|
+
Variable,
|
|
19
|
+
)
|
|
20
|
+
|
|
21
|
+
__version__ = "0.0.1"
|
|
22
|
+
|
|
23
|
+
__all__ = [
|
|
24
|
+
"Claim",
|
|
25
|
+
"Context",
|
|
26
|
+
"Direction",
|
|
27
|
+
"Effect",
|
|
28
|
+
"Method",
|
|
29
|
+
"Provenance",
|
|
30
|
+
"Relation",
|
|
31
|
+
"Role",
|
|
32
|
+
"Source",
|
|
33
|
+
"Variable",
|
|
34
|
+
"__version__",
|
|
35
|
+
]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Explanation of contradictions through context and method moderators. Work package WP06."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Claim extraction from sentences into the Claim schema. Work package WP03."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Ranking of research gaps by expected value of information. Work package WP07."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Aggregated claim graph with provenance and export. Work package WP05."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Data ingestion: OpenAlex metadata, abstracts, provenance. Work package WP02."""
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""Normalisation of equivalent constructs and variables across papers. Work package WP04."""
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
"""Claim schema v0.1.
|
|
2
|
+
|
|
3
|
+
A claim is one empirical statement from a paper, stored with the context and
|
|
4
|
+
method needed to explain why another study may disagree. The schema is small
|
|
5
|
+
on purpose: it conditions annotation (WP09) and extraction (WP03).
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
from enum import Enum
|
|
11
|
+
|
|
12
|
+
from pydantic import BaseModel, ConfigDict, Field, model_validator
|
|
13
|
+
|
|
14
|
+
SCHEMA_VERSION = "0.1"
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Role(str, Enum):
|
|
18
|
+
"""Role of a variable inside a claim."""
|
|
19
|
+
|
|
20
|
+
INDEPENDENT = "independent"
|
|
21
|
+
DEPENDENT = "dependent"
|
|
22
|
+
MODERATOR = "moderator"
|
|
23
|
+
MEDIATOR = "mediator"
|
|
24
|
+
CONTROL = "control"
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class Direction(str, Enum):
|
|
28
|
+
"""Direction of the reported relation."""
|
|
29
|
+
|
|
30
|
+
POSITIVE = "positive"
|
|
31
|
+
NEGATIVE = "negative"
|
|
32
|
+
NULL = "null"
|
|
33
|
+
MIXED = "mixed"
|
|
34
|
+
NON_MONOTONIC = "non_monotonic"
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class RelationKind(str, Enum):
|
|
38
|
+
"""What the authors say the relation is."""
|
|
39
|
+
|
|
40
|
+
CAUSAL = "causal"
|
|
41
|
+
ASSOCIATIVE = "associative"
|
|
42
|
+
PREDICTIVE = "predictive"
|
|
43
|
+
COMPARATIVE = "comparative"
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class Design(str, Enum):
|
|
47
|
+
"""Study design."""
|
|
48
|
+
|
|
49
|
+
EXPERIMENT = "experiment"
|
|
50
|
+
QUASI_EXPERIMENT = "quasi_experiment"
|
|
51
|
+
SURVEY = "survey"
|
|
52
|
+
PANEL = "panel"
|
|
53
|
+
CROSS_SECTION = "cross_section"
|
|
54
|
+
CASE_STUDY = "case_study"
|
|
55
|
+
QUALITATIVE = "qualitative"
|
|
56
|
+
SIMULATION = "simulation"
|
|
57
|
+
META_ANALYSIS = "meta_analysis"
|
|
58
|
+
OTHER = "other"
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
class Level(str, Enum):
|
|
62
|
+
"""Unit of analysis."""
|
|
63
|
+
|
|
64
|
+
INDIVIDUAL = "individual"
|
|
65
|
+
TEAM = "team"
|
|
66
|
+
FIRM = "firm"
|
|
67
|
+
INDUSTRY = "industry"
|
|
68
|
+
COUNTRY = "country"
|
|
69
|
+
OTHER = "other"
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class _Model(BaseModel):
|
|
73
|
+
model_config = ConfigDict(extra="forbid", use_enum_values=False)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
class Source(_Model):
|
|
77
|
+
"""Paper the claim comes from."""
|
|
78
|
+
|
|
79
|
+
doi: str | None = Field(default=None, description="DOI, without URL prefix.")
|
|
80
|
+
openalex_id: str | None = None
|
|
81
|
+
title: str | None = None
|
|
82
|
+
year: int | None = Field(default=None, ge=1500, le=2200)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
class Variable(_Model):
|
|
86
|
+
"""A variable as written in the paper, plus an optional normalised construct id."""
|
|
87
|
+
|
|
88
|
+
name: str = Field(min_length=1, description="Surface form in the paper.")
|
|
89
|
+
role: Role
|
|
90
|
+
construct_id: str | None = Field(
|
|
91
|
+
default=None, description="Id of the normalised construct (set by WP04)."
|
|
92
|
+
)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
class Relation(_Model):
|
|
96
|
+
"""Reported relation between the independent and dependent variables."""
|
|
97
|
+
|
|
98
|
+
direction: Direction
|
|
99
|
+
kind: RelationKind = RelationKind.ASSOCIATIVE
|
|
100
|
+
supported: bool | None = Field(
|
|
101
|
+
default=None, description="Whether the paper reports its hypothesis as supported."
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
class Effect(_Model):
|
|
106
|
+
"""Quantitative result, when the paper reports one."""
|
|
107
|
+
|
|
108
|
+
measure: str = Field(description="For example r, beta, d, OR, odds ratio.")
|
|
109
|
+
value: float
|
|
110
|
+
ci_low: float | None = None
|
|
111
|
+
ci_high: float | None = None
|
|
112
|
+
p_value: float | None = Field(default=None, ge=0, le=1)
|
|
113
|
+
n: int | None = Field(default=None, ge=0)
|
|
114
|
+
|
|
115
|
+
|
|
116
|
+
class Context(_Model):
|
|
117
|
+
"""Where and on whom the claim holds."""
|
|
118
|
+
|
|
119
|
+
population: str | None = Field(default=None, description="For example listed firms.")
|
|
120
|
+
country: str | None = Field(default=None, description="Country or region, as written.")
|
|
121
|
+
period: str | None = Field(default=None, description="For example 2008-2019.")
|
|
122
|
+
industry: str | None = None
|
|
123
|
+
level: Level | None = None
|
|
124
|
+
sample_size: int | None = Field(default=None, ge=0)
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
class Method(_Model):
|
|
128
|
+
"""How the claim was obtained."""
|
|
129
|
+
|
|
130
|
+
design: Design = Design.OTHER
|
|
131
|
+
estimator: str | None = Field(default=None, description="For example OLS, fixed effects, SEM.")
|
|
132
|
+
data_source: str | None = None
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
class Provenance(_Model):
|
|
136
|
+
"""Who or what produced this record, for reproducibility."""
|
|
137
|
+
|
|
138
|
+
extractor: str = Field(description="Human annotator id or extractor name.")
|
|
139
|
+
model: str | None = None
|
|
140
|
+
version: str | None = None
|
|
141
|
+
run_id: str | None = None
|
|
142
|
+
confidence: float | None = Field(default=None, ge=0, le=1)
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
class Claim(_Model):
|
|
146
|
+
"""One empirical claim with its evidence, context and method."""
|
|
147
|
+
|
|
148
|
+
id: str = Field(min_length=1)
|
|
149
|
+
schema_version: str = SCHEMA_VERSION
|
|
150
|
+
source: Source
|
|
151
|
+
sentence: str = Field(min_length=1, description="Sentence the claim was taken from, verbatim.")
|
|
152
|
+
section: str | None = Field(
|
|
153
|
+
default=None, description="Where it appears. Abstract-only pipeline: normally abstract."
|
|
154
|
+
)
|
|
155
|
+
variables: list[Variable] = Field(min_length=2)
|
|
156
|
+
relation: Relation
|
|
157
|
+
effect: Effect | None = None
|
|
158
|
+
context: Context = Field(default_factory=Context)
|
|
159
|
+
method: Method = Field(default_factory=Method)
|
|
160
|
+
provenance: Provenance
|
|
161
|
+
|
|
162
|
+
@model_validator(mode="after")
|
|
163
|
+
def _needs_independent_and_dependent(self) -> Claim:
|
|
164
|
+
roles = {v.role for v in self.variables}
|
|
165
|
+
if Role.INDEPENDENT not in roles or Role.DEPENDENT not in roles:
|
|
166
|
+
raise ValueError("a claim needs at least one independent and one dependent variable")
|
|
167
|
+
return self
|
|
168
|
+
|
|
169
|
+
def variables_with_role(self, role: Role) -> list[Variable]:
|
|
170
|
+
"""Return the variables that have the given role."""
|
|
171
|
+
return [v for v in self.variables if v.role == role]
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import scitheory
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def test_version():
|
|
5
|
+
assert scitheory.__version__ == "0.0.1"
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def test_submodules_import():
|
|
9
|
+
import scitheory.explain
|
|
10
|
+
import scitheory.extract
|
|
11
|
+
import scitheory.gaps
|
|
12
|
+
import scitheory.graph
|
|
13
|
+
import scitheory.ingest
|
|
14
|
+
import scitheory.normalize # noqa: F401
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import json
|
|
2
|
+
from pathlib import Path
|
|
3
|
+
|
|
4
|
+
import pytest
|
|
5
|
+
from pydantic import ValidationError
|
|
6
|
+
|
|
7
|
+
from scitheory import Claim, Direction, Role
|
|
8
|
+
|
|
9
|
+
EXAMPLES = Path(__file__).resolve().parents[1] / "examples" / "claims_synthetic.json"
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def load():
|
|
13
|
+
return json.loads(EXAMPLES.read_text(encoding="utf-8"))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def test_examples_validate():
|
|
17
|
+
claims = [Claim.model_validate(c) for c in load()]
|
|
18
|
+
assert len(claims) == 3
|
|
19
|
+
assert claims[0].relation.direction is Direction.NEGATIVE
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def test_roundtrip():
|
|
23
|
+
claim = Claim.model_validate(load()[0])
|
|
24
|
+
again = Claim.model_validate_json(claim.model_dump_json())
|
|
25
|
+
assert again == claim
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
def test_variables_with_role():
|
|
29
|
+
claim = Claim.model_validate(load()[2])
|
|
30
|
+
moderators = claim.variables_with_role(Role.MODERATOR)
|
|
31
|
+
assert [v.name for v in moderators] == ["ownership concentration"]
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
def test_needs_independent_and_dependent():
|
|
35
|
+
data = load()[0]
|
|
36
|
+
data["variables"] = [{"name": "a", "role": "independent"}, {"name": "b", "role": "control"}]
|
|
37
|
+
with pytest.raises(ValidationError):
|
|
38
|
+
Claim.model_validate(data)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def test_rejects_unknown_fields():
|
|
42
|
+
data = load()[0]
|
|
43
|
+
data["surprise"] = 1
|
|
44
|
+
with pytest.raises(ValidationError):
|
|
45
|
+
Claim.model_validate(data)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def test_p_value_range():
|
|
49
|
+
data = load()[0]
|
|
50
|
+
data["effect"]["p_value"] = 1.5
|
|
51
|
+
with pytest.raises(ValidationError):
|
|
52
|
+
Claim.model_validate(data)
|