keyrecon 0.1.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.
- keyrecon-0.1.0/LICENSE +21 -0
- keyrecon-0.1.0/PKG-INFO +175 -0
- keyrecon-0.1.0/README.md +145 -0
- keyrecon-0.1.0/pyproject.toml +69 -0
- keyrecon-0.1.0/setup.cfg +4 -0
- keyrecon-0.1.0/src/keyrecon/__init__.py +12 -0
- keyrecon-0.1.0/src/keyrecon/candidate_table.py +51 -0
- keyrecon-0.1.0/src/keyrecon/candidates/__init__.py +4 -0
- keyrecon-0.1.0/src/keyrecon/candidates/english_reference.py +295 -0
- keyrecon-0.1.0/src/keyrecon/candidates/generic.py +77 -0
- keyrecon-0.1.0/src/keyrecon/canonical.py +42 -0
- keyrecon-0.1.0/src/keyrecon/cli.py +120 -0
- keyrecon-0.1.0/src/keyrecon/config.py +68 -0
- keyrecon-0.1.0/src/keyrecon/core/__init__.py +16 -0
- keyrecon-0.1.0/src/keyrecon/core/calibration.py +121 -0
- keyrecon-0.1.0/src/keyrecon/core/features.py +186 -0
- keyrecon-0.1.0/src/keyrecon/core/metrics.py +81 -0
- keyrecon-0.1.0/src/keyrecon/core/provenance.py +45 -0
- keyrecon-0.1.0/src/keyrecon/core/scoring.py +49 -0
- keyrecon-0.1.0/src/keyrecon/core/weights.py +50 -0
- keyrecon-0.1.0/src/keyrecon/engine.py +249 -0
- keyrecon-0.1.0/src/keyrecon/languages/__init__.py +4 -0
- keyrecon-0.1.0/src/keyrecon/languages/base.py +131 -0
- keyrecon-0.1.0/src/keyrecon/languages/registry.py +57 -0
- keyrecon-0.1.0/src/keyrecon/normalization.py +21 -0
- keyrecon-0.1.0/src/keyrecon/profiles/en_reference.json +56 -0
- keyrecon-0.1.0/src/keyrecon/profiles/ja_experimental.json +15 -0
- keyrecon-0.1.0/src/keyrecon/profiles/ko_experimental.json +14 -0
- keyrecon-0.1.0/src/keyrecon/profiles/zh_experimental.json +15 -0
- keyrecon-0.1.0/src/keyrecon/version.py +1 -0
- keyrecon-0.1.0/src/keyrecon.egg-info/PKG-INFO +175 -0
- keyrecon-0.1.0/src/keyrecon.egg-info/SOURCES.txt +43 -0
- keyrecon-0.1.0/src/keyrecon.egg-info/dependency_links.txt +1 -0
- keyrecon-0.1.0/src/keyrecon.egg-info/entry_points.txt +2 -0
- keyrecon-0.1.0/src/keyrecon.egg-info/requires.txt +13 -0
- keyrecon-0.1.0/src/keyrecon.egg-info/top_level.txt +1 -0
- keyrecon-0.1.0/tests/test_calibration.py +27 -0
- keyrecon-0.1.0/tests/test_config.py +4 -0
- keyrecon-0.1.0/tests/test_english_rule.py +38 -0
- keyrecon-0.1.0/tests/test_features.py +27 -0
- keyrecon-0.1.0/tests/test_language_registry.py +9 -0
- keyrecon-0.1.0/tests/test_normalization.py +5 -0
- keyrecon-0.1.0/tests/test_profiles.py +9 -0
- keyrecon-0.1.0/tests/test_scoring.py +33 -0
- keyrecon-0.1.0/tests/test_weights.py +6 -0
keyrecon-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Byong-Rae Ryu and Sunghwa Lee
|
|
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.
|
keyrecon-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: keyrecon
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Author-keyword reconstruction with Adaptive Composite Keyword Scoring (Adaptive CKS)
|
|
5
|
+
Author: Byong-Rae Ryu, Sunghwa Lee
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Keywords: keyword reconstruction,author keywords,bibliometrics,keyphrase extraction,spaCy,Adaptive CKS
|
|
8
|
+
Classifier: Development Status :: 3 - Alpha
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
14
|
+
Classifier: Topic :: Text Processing :: Linguistic
|
|
15
|
+
Classifier: Topic :: Scientific/Engineering :: Information Analysis
|
|
16
|
+
Requires-Python: >=3.10
|
|
17
|
+
Description-Content-Type: text/markdown
|
|
18
|
+
License-File: LICENSE
|
|
19
|
+
Requires-Dist: numpy<3,>=1.26
|
|
20
|
+
Requires-Dist: pandas<4,>=2.0
|
|
21
|
+
Provides-Extra: nlp
|
|
22
|
+
Requires-Dist: spacy<4,>=3.8; extra == "nlp"
|
|
23
|
+
Provides-Extra: transformers
|
|
24
|
+
Requires-Dist: spacy<4,>=3.8; extra == "transformers"
|
|
25
|
+
Requires-Dist: spacy-transformers<2,>=1.3; extra == "transformers"
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: pytest<10,>=8; extra == "dev"
|
|
28
|
+
Requires-Dist: build<2,>=1.2; extra == "dev"
|
|
29
|
+
Dynamic: license-file
|
|
30
|
+
|
|
31
|
+
# KeyRecon
|
|
32
|
+
|
|
33
|
+
**KeyRecon** is a Python toolkit for reconstructing missing author keywords using
|
|
34
|
+
**Adaptive Composite Keyword Scoring (Adaptive CKS)**.
|
|
35
|
+
|
|
36
|
+
KeyRecon treats missing author keywords as a metadata-reconstruction problem rather
|
|
37
|
+
than as unrestricted keyword extraction. It separates candidate generation, canonicalization,
|
|
38
|
+
feature fitting, composite scoring, decision-threshold calibration, ranking, and provenance.
|
|
39
|
+
|
|
40
|
+
## Status
|
|
41
|
+
|
|
42
|
+
- **English (`en_reference`)**: reference implementation of the frozen Adaptive CKS architecture.
|
|
43
|
+
- **Chinese (`zh_experimental`)**: experimental language adapter.
|
|
44
|
+
- **Japanese (`ja_experimental`)**: experimental language adapter.
|
|
45
|
+
- **Korean (`ko_experimental`)**: experimental language adapter.
|
|
46
|
+
|
|
47
|
+
The multilingual adapters are deliberately marked **experimental**. The Adaptive CKS paper
|
|
48
|
+
evaluates the English reference architecture; it does not establish that the same candidate
|
|
49
|
+
policy, weights, or thresholds are optimal in Chinese, Japanese, or Korean.
|
|
50
|
+
|
|
51
|
+
## Why KeyRecon?
|
|
52
|
+
|
|
53
|
+
Ordinary keyword extraction asks which expressions are salient in a document.
|
|
54
|
+
KeyRecon instead assumes that author-keyword metadata are observed for some records and
|
|
55
|
+
genuinely missing for others. Observed records can therefore supply development-only evidence,
|
|
56
|
+
while missing records are reconstruction targets. Observed author keywords are never overwritten.
|
|
57
|
+
|
|
58
|
+
## Install for development
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
python -m pip install -e ".[dev,nlp]"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
For transformer profiles:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
python -m pip install -e ".[dev,transformers]"
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
Then install the spaCy pipeline explicitly:
|
|
71
|
+
|
|
72
|
+
```bash
|
|
73
|
+
python -m spacy download en_core_web_trf
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Available KeyRecon profiles can be inspected with:
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
keyrecon models
|
|
80
|
+
keyrecon setup --lang en
|
|
81
|
+
keyrecon profile --lang en
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## Minimal CSV workflow
|
|
85
|
+
|
|
86
|
+
Input:
|
|
87
|
+
|
|
88
|
+
```csv
|
|
89
|
+
record_id,title,abstract,author_keywords
|
|
90
|
+
d1,Sign language phonology,This paper studies phonological structure in sign language,sign language;phonology
|
|
91
|
+
d2,Syntactic movement,We investigate long-distance movement and locality,movement;locality
|
|
92
|
+
d3,Visual language structure,The analysis examines phonological patterning in a visual language,
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Run:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
keyrecon run input.csv predictions.csv --lang en --mode adaptive
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
`--mode adaptive` searches the prespecified 61-weight × 13-threshold Adaptive CKS space
|
|
102
|
+
using development-only out-of-fold evidence from records with observed author keywords.
|
|
103
|
+
|
|
104
|
+
For an English reference-weight run with development-only threshold calibration:
|
|
105
|
+
|
|
106
|
+
```bash
|
|
107
|
+
keyrecon run input.csv predictions.csv --lang en --mode reference
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
The command writes a long-form prediction CSV and a JSON run manifest.
|
|
111
|
+
|
|
112
|
+
## Python API
|
|
113
|
+
|
|
114
|
+
```python
|
|
115
|
+
import pandas as pd
|
|
116
|
+
from keyrecon import KeyRecon
|
|
117
|
+
|
|
118
|
+
records = pd.read_csv("input.csv", keep_default_na=False)
|
|
119
|
+
|
|
120
|
+
model = KeyRecon(language="en", mode="adaptive")
|
|
121
|
+
predictions = model.fit_reconstruct_missing(records)
|
|
122
|
+
|
|
123
|
+
print(model.fit_summary_)
|
|
124
|
+
print(predictions[["record_id", "canonical_key", "cks_score", "rank"]])
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Language profiles
|
|
128
|
+
|
|
129
|
+
| code | profile | spaCy pipeline | status |
|
|
130
|
+
|---|---|---|---|
|
|
131
|
+
| `en` | `en_reference` | `en_core_web_trf` | reference |
|
|
132
|
+
| `zh` | `zh_experimental` | `zh_core_web_trf` | experimental |
|
|
133
|
+
| `ja` | `ja_experimental` | `ja_core_news_trf` | experimental |
|
|
134
|
+
| `ko` | `ko_experimental` | `ko_core_news_lg` | experimental |
|
|
135
|
+
|
|
136
|
+
Language selection is explicit for reproducibility. Automatic language detection is intentionally
|
|
137
|
+
not enabled in v0.1.0.
|
|
138
|
+
|
|
139
|
+
## Scientific boundary
|
|
140
|
+
|
|
141
|
+
The English reference profile preserves the study's key invariants:
|
|
142
|
+
|
|
143
|
+
- title and abstract are parsed independently before candidate union;
|
|
144
|
+
- the reference candidate span is 1–4 lexical units;
|
|
145
|
+
- source provenance is retained and no title score bonus is used;
|
|
146
|
+
- the five score components are TF–IDF, document frequency, dispersion, domain focus,
|
|
147
|
+
and phrase quality;
|
|
148
|
+
- the operational decision score is rounded to 12 decimals;
|
|
149
|
+
- eligibility is inclusive (`rounded_score >= threshold`);
|
|
150
|
+
- ranking is score-descending with canonical-key ascending as deterministic tie-break;
|
|
151
|
+
- at most 10 predictions are returned;
|
|
152
|
+
- no below-threshold fallback is used.
|
|
153
|
+
|
|
154
|
+
The public package does **not** bundle licensed Web of Science records, abstracts, held-out gold
|
|
155
|
+
labels, or the full corpus-derived canonical mapping. Therefore exact paper-level replay also
|
|
156
|
+
requires the private/licensed frozen research assets. The package provides the algorithmic
|
|
157
|
+
reference implementation and provenance hashes for those external frozen assets.
|
|
158
|
+
|
|
159
|
+
See `docs/scientific_boundary.md` and `docs/reproducibility.md`.
|
|
160
|
+
|
|
161
|
+
## Multilingual design
|
|
162
|
+
|
|
163
|
+
The Adaptive CKS scoring core is separated from the language adapter. Replacing the NLP model
|
|
164
|
+
alone is not treated as sufficient evidence of multilingual validity: tokenization, candidate
|
|
165
|
+
boundaries, POS behavior, and PhraseQuality are language-sensitive.
|
|
166
|
+
|
|
167
|
+
See `docs/multilingual.md`.
|
|
168
|
+
|
|
169
|
+
## Citation
|
|
170
|
+
|
|
171
|
+
See `CITATION.cff`.
|
|
172
|
+
|
|
173
|
+
## License
|
|
174
|
+
|
|
175
|
+
MIT.
|
keyrecon-0.1.0/README.md
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
# KeyRecon
|
|
2
|
+
|
|
3
|
+
**KeyRecon** is a Python toolkit for reconstructing missing author keywords using
|
|
4
|
+
**Adaptive Composite Keyword Scoring (Adaptive CKS)**.
|
|
5
|
+
|
|
6
|
+
KeyRecon treats missing author keywords as a metadata-reconstruction problem rather
|
|
7
|
+
than as unrestricted keyword extraction. It separates candidate generation, canonicalization,
|
|
8
|
+
feature fitting, composite scoring, decision-threshold calibration, ranking, and provenance.
|
|
9
|
+
|
|
10
|
+
## Status
|
|
11
|
+
|
|
12
|
+
- **English (`en_reference`)**: reference implementation of the frozen Adaptive CKS architecture.
|
|
13
|
+
- **Chinese (`zh_experimental`)**: experimental language adapter.
|
|
14
|
+
- **Japanese (`ja_experimental`)**: experimental language adapter.
|
|
15
|
+
- **Korean (`ko_experimental`)**: experimental language adapter.
|
|
16
|
+
|
|
17
|
+
The multilingual adapters are deliberately marked **experimental**. The Adaptive CKS paper
|
|
18
|
+
evaluates the English reference architecture; it does not establish that the same candidate
|
|
19
|
+
policy, weights, or thresholds are optimal in Chinese, Japanese, or Korean.
|
|
20
|
+
|
|
21
|
+
## Why KeyRecon?
|
|
22
|
+
|
|
23
|
+
Ordinary keyword extraction asks which expressions are salient in a document.
|
|
24
|
+
KeyRecon instead assumes that author-keyword metadata are observed for some records and
|
|
25
|
+
genuinely missing for others. Observed records can therefore supply development-only evidence,
|
|
26
|
+
while missing records are reconstruction targets. Observed author keywords are never overwritten.
|
|
27
|
+
|
|
28
|
+
## Install for development
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
python -m pip install -e ".[dev,nlp]"
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
For transformer profiles:
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
python -m pip install -e ".[dev,transformers]"
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Then install the spaCy pipeline explicitly:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
python -m spacy download en_core_web_trf
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Available KeyRecon profiles can be inspected with:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
keyrecon models
|
|
50
|
+
keyrecon setup --lang en
|
|
51
|
+
keyrecon profile --lang en
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
## Minimal CSV workflow
|
|
55
|
+
|
|
56
|
+
Input:
|
|
57
|
+
|
|
58
|
+
```csv
|
|
59
|
+
record_id,title,abstract,author_keywords
|
|
60
|
+
d1,Sign language phonology,This paper studies phonological structure in sign language,sign language;phonology
|
|
61
|
+
d2,Syntactic movement,We investigate long-distance movement and locality,movement;locality
|
|
62
|
+
d3,Visual language structure,The analysis examines phonological patterning in a visual language,
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Run:
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
keyrecon run input.csv predictions.csv --lang en --mode adaptive
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`--mode adaptive` searches the prespecified 61-weight × 13-threshold Adaptive CKS space
|
|
72
|
+
using development-only out-of-fold evidence from records with observed author keywords.
|
|
73
|
+
|
|
74
|
+
For an English reference-weight run with development-only threshold calibration:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
keyrecon run input.csv predictions.csv --lang en --mode reference
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The command writes a long-form prediction CSV and a JSON run manifest.
|
|
81
|
+
|
|
82
|
+
## Python API
|
|
83
|
+
|
|
84
|
+
```python
|
|
85
|
+
import pandas as pd
|
|
86
|
+
from keyrecon import KeyRecon
|
|
87
|
+
|
|
88
|
+
records = pd.read_csv("input.csv", keep_default_na=False)
|
|
89
|
+
|
|
90
|
+
model = KeyRecon(language="en", mode="adaptive")
|
|
91
|
+
predictions = model.fit_reconstruct_missing(records)
|
|
92
|
+
|
|
93
|
+
print(model.fit_summary_)
|
|
94
|
+
print(predictions[["record_id", "canonical_key", "cks_score", "rank"]])
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
## Language profiles
|
|
98
|
+
|
|
99
|
+
| code | profile | spaCy pipeline | status |
|
|
100
|
+
|---|---|---|---|
|
|
101
|
+
| `en` | `en_reference` | `en_core_web_trf` | reference |
|
|
102
|
+
| `zh` | `zh_experimental` | `zh_core_web_trf` | experimental |
|
|
103
|
+
| `ja` | `ja_experimental` | `ja_core_news_trf` | experimental |
|
|
104
|
+
| `ko` | `ko_experimental` | `ko_core_news_lg` | experimental |
|
|
105
|
+
|
|
106
|
+
Language selection is explicit for reproducibility. Automatic language detection is intentionally
|
|
107
|
+
not enabled in v0.1.0.
|
|
108
|
+
|
|
109
|
+
## Scientific boundary
|
|
110
|
+
|
|
111
|
+
The English reference profile preserves the study's key invariants:
|
|
112
|
+
|
|
113
|
+
- title and abstract are parsed independently before candidate union;
|
|
114
|
+
- the reference candidate span is 1–4 lexical units;
|
|
115
|
+
- source provenance is retained and no title score bonus is used;
|
|
116
|
+
- the five score components are TF–IDF, document frequency, dispersion, domain focus,
|
|
117
|
+
and phrase quality;
|
|
118
|
+
- the operational decision score is rounded to 12 decimals;
|
|
119
|
+
- eligibility is inclusive (`rounded_score >= threshold`);
|
|
120
|
+
- ranking is score-descending with canonical-key ascending as deterministic tie-break;
|
|
121
|
+
- at most 10 predictions are returned;
|
|
122
|
+
- no below-threshold fallback is used.
|
|
123
|
+
|
|
124
|
+
The public package does **not** bundle licensed Web of Science records, abstracts, held-out gold
|
|
125
|
+
labels, or the full corpus-derived canonical mapping. Therefore exact paper-level replay also
|
|
126
|
+
requires the private/licensed frozen research assets. The package provides the algorithmic
|
|
127
|
+
reference implementation and provenance hashes for those external frozen assets.
|
|
128
|
+
|
|
129
|
+
See `docs/scientific_boundary.md` and `docs/reproducibility.md`.
|
|
130
|
+
|
|
131
|
+
## Multilingual design
|
|
132
|
+
|
|
133
|
+
The Adaptive CKS scoring core is separated from the language adapter. Replacing the NLP model
|
|
134
|
+
alone is not treated as sufficient evidence of multilingual validity: tokenization, candidate
|
|
135
|
+
boundaries, POS behavior, and PhraseQuality are language-sensitive.
|
|
136
|
+
|
|
137
|
+
See `docs/multilingual.md`.
|
|
138
|
+
|
|
139
|
+
## Citation
|
|
140
|
+
|
|
141
|
+
See `CITATION.cff`.
|
|
142
|
+
|
|
143
|
+
## License
|
|
144
|
+
|
|
145
|
+
MIT.
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=77", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "keyrecon"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Author-keyword reconstruction with Adaptive Composite Keyword Scoring (Adaptive CKS)"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [
|
|
14
|
+
{name = "Byong-Rae Ryu"},
|
|
15
|
+
{name = "Sunghwa Lee"},
|
|
16
|
+
]
|
|
17
|
+
keywords = [
|
|
18
|
+
"keyword reconstruction",
|
|
19
|
+
"author keywords",
|
|
20
|
+
"bibliometrics",
|
|
21
|
+
"keyphrase extraction",
|
|
22
|
+
"spaCy",
|
|
23
|
+
"Adaptive CKS",
|
|
24
|
+
]
|
|
25
|
+
classifiers = [
|
|
26
|
+
"Development Status :: 3 - Alpha",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Topic :: Text Processing :: Linguistic",
|
|
33
|
+
"Topic :: Scientific/Engineering :: Information Analysis",
|
|
34
|
+
]
|
|
35
|
+
dependencies = [
|
|
36
|
+
"numpy>=1.26,<3",
|
|
37
|
+
"pandas>=2.0,<4",
|
|
38
|
+
]
|
|
39
|
+
|
|
40
|
+
[project.optional-dependencies]
|
|
41
|
+
nlp = [
|
|
42
|
+
"spacy>=3.8,<4",
|
|
43
|
+
]
|
|
44
|
+
transformers = [
|
|
45
|
+
"spacy>=3.8,<4",
|
|
46
|
+
"spacy-transformers>=1.3,<2",
|
|
47
|
+
]
|
|
48
|
+
dev = [
|
|
49
|
+
"pytest>=8,<10",
|
|
50
|
+
"build>=1.2,<2",
|
|
51
|
+
]
|
|
52
|
+
|
|
53
|
+
[project.scripts]
|
|
54
|
+
keyrecon = "keyrecon.cli:main"
|
|
55
|
+
|
|
56
|
+
[tool.setuptools]
|
|
57
|
+
package-dir = {"" = "src"}
|
|
58
|
+
include-package-data = true
|
|
59
|
+
|
|
60
|
+
[tool.setuptools.packages.find]
|
|
61
|
+
where = ["src"]
|
|
62
|
+
|
|
63
|
+
[tool.setuptools.package-data]
|
|
64
|
+
keyrecon = ["profiles/*.json"]
|
|
65
|
+
|
|
66
|
+
[tool.pytest.ini_options]
|
|
67
|
+
testpaths = ["tests"]
|
|
68
|
+
pythonpath = ["src"]
|
|
69
|
+
addopts = "-q"
|
keyrecon-0.1.0/setup.cfg
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"""KeyRecon: author-keyword reconstruction with Adaptive CKS."""
|
|
2
|
+
|
|
3
|
+
from .version import __version__
|
|
4
|
+
from .engine import KeyRecon
|
|
5
|
+
from .config import AdaptiveCKSWeights, EN_REFERENCE_WEIGHTS
|
|
6
|
+
|
|
7
|
+
__all__ = [
|
|
8
|
+
"__version__",
|
|
9
|
+
"KeyRecon",
|
|
10
|
+
"AdaptiveCKSWeights",
|
|
11
|
+
"EN_REFERENCE_WEIGHTS",
|
|
12
|
+
]
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
from .canonical import Canonicalizer
|
|
6
|
+
from .languages.base import LanguageAdapter
|
|
7
|
+
|
|
8
|
+
def aggregate_candidates(
|
|
9
|
+
occurrences: pd.DataFrame,
|
|
10
|
+
canonicalizer: Canonicalizer,
|
|
11
|
+
adapter: LanguageAdapter,
|
|
12
|
+
) -> pd.DataFrame:
|
|
13
|
+
if occurrences.empty:
|
|
14
|
+
return pd.DataFrame(columns=[
|
|
15
|
+
"record_id", "canonical_key", "candidate_length",
|
|
16
|
+
"total_occurrence_count", "title_occurrence_count",
|
|
17
|
+
"abstract_occurrence_count", "source_class", "representative_surface",
|
|
18
|
+
])
|
|
19
|
+
work = occurrences.copy()
|
|
20
|
+
work["canonical_key"] = work["candidate_exact_key"].map(canonicalizer)
|
|
21
|
+
work = work.loc[work["canonical_key"].astype(str).str.strip().ne("")].copy()
|
|
22
|
+
|
|
23
|
+
rows = []
|
|
24
|
+
for (rid, canonical), group in work.groupby(["record_id", "canonical_key"], sort=True):
|
|
25
|
+
title_n = int(group["source_field"].eq("TITLE").sum())
|
|
26
|
+
abstract_n = int(group["source_field"].eq("ABSTRACT").sum())
|
|
27
|
+
if title_n and abstract_n:
|
|
28
|
+
source_class = "TITLE_AND_ABSTRACT"
|
|
29
|
+
elif title_n:
|
|
30
|
+
source_class = "TITLE_ONLY"
|
|
31
|
+
else:
|
|
32
|
+
source_class = "ABSTRACT_ONLY"
|
|
33
|
+
surface_counts = (
|
|
34
|
+
group.groupby("candidate_surface").size()
|
|
35
|
+
.sort_values(ascending=False, kind="stable")
|
|
36
|
+
)
|
|
37
|
+
max_count = int(surface_counts.max())
|
|
38
|
+
representative = sorted(surface_counts.loc[surface_counts.eq(max_count)].index.astype(str))[0]
|
|
39
|
+
fallback_length = int(group.loc[group["candidate_surface"].astype(str).eq(representative),
|
|
40
|
+
"lexical_unit_count"].iloc[0])
|
|
41
|
+
rows.append({
|
|
42
|
+
"record_id": str(rid),
|
|
43
|
+
"canonical_key": str(canonical),
|
|
44
|
+
"candidate_length": adapter.canonical_length(str(canonical), fallback=fallback_length),
|
|
45
|
+
"total_occurrence_count": int(len(group)),
|
|
46
|
+
"title_occurrence_count": title_n,
|
|
47
|
+
"abstract_occurrence_count": abstract_n,
|
|
48
|
+
"source_class": source_class,
|
|
49
|
+
"representative_surface": representative,
|
|
50
|
+
})
|
|
51
|
+
return pd.DataFrame(rows)
|