scitheory 0.0.1__py3-none-any.whl

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/__init__.py ADDED
@@ -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."""
scitheory/schema.py ADDED
@@ -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,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,12 @@
1
+ scitheory/__init__.py,sha256=h3KZWcr3-tvB3I_hu59nMiUGKzh2EeYOXgf0PSDGZgI,691
2
+ scitheory/schema.py,sha256=xmfCp11HzYpFeehj-v421veGntwQ6CtPcXXPRRSG6tU,5283
3
+ scitheory/explain/__init__.py,sha256=MgyjsCUYwKyQ4dh5fptMENxAtUBUotlY0izxQJlJVZE,95
4
+ scitheory/extract/__init__.py,sha256=K6kIYkf5lQT4AGdKd1vmjVk1EvxzkpLHxzUVtIoQaQg,81
5
+ scitheory/gaps/__init__.py,sha256=ePrb-nZ_wf3U6yNdKDXzgYWDi2puJsKVEG0TDJ-GdPw,85
6
+ scitheory/graph/__init__.py,sha256=uKKnvR7Pmlh24MTWC3Wc7VuvQDDWmMZF7HaDHz8oRiA,77
7
+ scitheory/ingest/__init__.py,sha256=F9CvdVwCJDK3sGzV1axubuljqoRzGo5PKWCzuPCjiXc,84
8
+ scitheory/normalize/__init__.py,sha256=nwzvbounaVrghF-9aEx3NMwx8qvX4sO70iGefDblBN8,94
9
+ scitheory-0.0.1.dist-info/METADATA,sha256=5_4E4b4Sz8jb9ZPQk3tP8bNd1GJJ5CDrk9G36Em2mvc,3702
10
+ scitheory-0.0.1.dist-info/WHEEL,sha256=W3fkpkm7-wf9vBI5Z-7s0eWkeM-spu78I8Neb98DeEg,87
11
+ scitheory-0.0.1.dist-info/licenses/LICENSE,sha256=nBgctRGy4VYyzUjcx9F7cm5Wqwg6yTK8pGWTbaJBiEs,1100
12
+ scitheory-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.32.4
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -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.