Metadata-Version: 2.5
Name: mad-search
Version: 0.2.0
Summary: Search OpenAlex for academic articles using YAML-frontmatter markdown files
Project-URL: Homepage, https://codeberg.org/divinemadman/mad-search
Project-URL: Repository, https://codeberg.org/divinemadman/mad-search.git
Project-URL: Issues, https://codeberg.org/divinemadman/mad-search/issues
Author-email: Divine Madman <divinemadman@proton.me>
License: MIT License
        
        Copyright (c) 2026 The mad-search authors
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
License-File: LICENSE
Requires-Python: >=3.13
Requires-Dist: pyalex>=0.21
Requires-Dist: pyyaml>=6.0
Description-Content-Type: text/markdown

# mad-search

[![Codeberg](https://img.shields.io/badge/hosted-Codeberg-2185D0?logo=codeberg)](https://codeberg.org/divinemadman/mad-search)

Search OpenAlex for academic articles using YAML-frontmatter markdown files.

## Requirements

- Python 3.13+
- A free [OpenAlex API key](https://openalex.org/settings/api)

## Installation

```bash
# run directly with uv
uv run mad-search path/to/search.md

# or install globally
uv tool install mad-search
```

## Usage

Create a markdown file with YAML frontmatter:

```markdown
---
api_key: your_key_here
query: "(machine learning AND climate) OR large language models"
journals:
  - Nature
  - Science
year_from: 2020
year_to: 2025
domains: 2
fields:
  - 17
topics:
  - T11636
---
```

Run it:

```bash
uv run mad-search search.md
```

Results are written to `out/<input>.md` (the input file is never modified — keeping your API key safe).

## Taxonomy ID lookup

`domains`, `fields`, `subfields`, and `topics` take raw OpenAlex IDs. Labels are resolved at startup and echoed next to the ID (`Domains: Social Sciences (2)`).

### Domains

| ID | Label |
|---|---|
| 1 | Life Sciences |
| 2 | Social Sciences |
| 3 | Physical Sciences |
| 4 | Health Sciences |

### Fields

| ID | Label |
|---|---|
| 11 | Agricultural and Biological Sciences |
| 12 | Arts and Humanities |
| 13 | Biochemistry, Genetics and Molecular Biology |
| 14 | Business, Management and Accounting |
| 15 | Chemical Engineering |
| 16 | Chemistry |
| 17 | Computer Science |
| 18 | Decision Sciences |
| 19 | Earth and Planetary Sciences |
| 20 | Economics, Econometrics and Finance |
| 21 | Energy |
| 22 | Engineering |
| 23 | Environmental Science |
| 24 | Immunology and Microbiology |
| 25 | Materials Science |
| 26 | Mathematics |
| 27 | Medicine |
| 28 | Neuroscience |
| 29 | Nursing |
| 30 | Pharmacology, Toxicology and Pharmaceutics |
| 31 | Physics and Astronomy |
| 32 | Psychology |
| 33 | Social Sciences |
| 34 | Veterinary |
| 35 | Dentistry |
| 36 | Health Professions |

### Subfields

252 subfields, e.g. `subfields: 1702` → Artificial Intelligence:

<details>
<summary>Show all 252 subfields</summary>

| ID | Label |
|---|---|
| 1100 | General Agricultural and Biological Sciences |
| 1102 | Agronomy and Crop Science |
| 1103 | Animal Science and Zoology |
| 1104 | Aquatic Science |
| 1105 | Ecology, Evolution, Behavior and Systematics |
| 1106 | Food Science |
| 1107 | Forestry |
| 1108 | Horticulture |
| 1109 | Insect Science |
| 1110 | Plant Science |
| 1111 | Soil Science |
| 1200 | General Arts and Humanities |
| 1202 | History |
| 1203 | Language and Linguistics |
| 1204 | Archeology |
| 1205 | Classics |
| 1206 | Conservation |
| 1207 | History and Philosophy of Science |
| 1208 | Literature and Literary Theory |
| 1209 | Museology |
| 1210 | Music |
| 1211 | Philosophy |
| 1212 | Religious studies |
| 1213 | Visual Arts and Performing Arts |
| 1302 | Aging |
| 1303 | Biochemistry |
| 1304 | Biophysics |
| 1305 | Biotechnology |
| 1306 | Cancer Research |
| 1307 | Cell Biology |
| 1308 | Clinical Biochemistry |
| 1309 | Developmental Biology |
| 1310 | Endocrinology |
| 1311 | Genetics |
| 1312 | Molecular Biology |
| 1313 | Molecular Medicine |
| 1314 | Physiology |
| 1315 | Structural Biology |
| 1402 | Accounting |
| 1403 | Business and International Management |
| 1404 | Management Information Systems |
| 1405 | Management of Technology and Innovation |
| 1406 | Marketing |
| 1407 | Organizational Behavior and Human Resource Management |
| 1408 | Strategy and Management |
| 1409 | Tourism, Leisure and Hospitality Management |
| 1410 | Industrial relations |
| 1502 | Bioengineering |
| 1503 | Catalysis |
| 1504 | Chemical Health and Safety |
| 1506 | Filtration and Separation |
| 1507 | Fluid Flow and Transfer Processes |
| 1508 | Process Chemistry and Technology |
| 1602 | Analytical Chemistry |
| 1603 | Electrochemistry |
| 1604 | Inorganic Chemistry |
| 1605 | Organic Chemistry |
| 1606 | Physical and Theoretical Chemistry |
| 1607 | Spectroscopy |
| 1702 | Artificial Intelligence |
| 1703 | Computational Theory and Mathematics |
| 1704 | Computer Graphics and Computer-Aided Design |
| 1705 | Computer Networks and Communications |
| 1706 | Computer Science Applications |
| 1707 | Computer Vision and Pattern Recognition |
| 1708 | Hardware and Architecture |
| 1709 | Human-Computer Interaction |
| 1710 | Information Systems |
| 1711 | Signal Processing |
| 1712 | Software |
| 1800 | General Decision Sciences |
| 1802 | Information Systems and Management |
| 1803 | Management Science and Operations Research |
| 1804 | Statistics, Probability and Uncertainty |
| 1902 | Atmospheric Science |
| 1904 | Earth-Surface Processes |
| 1906 | Geochemistry and Petrology |
| 1907 | Geology |
| 1908 | Geophysics |
| 1910 | Oceanography |
| 1911 | Paleontology |
| 1912 | Space and Planetary Science |
| 2000 | General Economics, Econometrics and Finance |
| 2002 | Economics and Econometrics |
| 2003 | Finance |
| 2100 | General Energy |
| 2102 | Energy Engineering and Power Technology |
| 2103 | Fuel Technology |
| 2104 | Nuclear Energy and Engineering |
| 2105 | Renewable Energy, Sustainability and the Environment |
| 2200 | General Engineering |
| 2202 | Aerospace Engineering |
| 2203 | Automotive Engineering |
| 2204 | Biomedical Engineering |
| 2205 | Civil and Structural Engineering |
| 2206 | Computational Mechanics |
| 2207 | Control and Systems Engineering |
| 2208 | Electrical and Electronic Engineering |
| 2209 | Industrial and Manufacturing Engineering |
| 2210 | Mechanical Engineering |
| 2211 | Mechanics of Materials |
| 2212 | Ocean Engineering |
| 2213 | Safety, Risk, Reliability and Quality |
| 2214 | Media Technology |
| 2215 | Building and Construction |
| 2216 | Architecture |
| 2302 | Ecological Modeling |
| 2303 | Ecology |
| 2304 | Environmental Chemistry |
| 2305 | Environmental Engineering |
| 2306 | Global and Planetary Change |
| 2307 | Health, Toxicology and Mutagenesis |
| 2308 | Management, Monitoring, Policy and Law |
| 2309 | Nature and Landscape Conservation |
| 2310 | Pollution |
| 2311 | Waste Management and Disposal |
| 2312 | Water Science and Technology |
| 2402 | Applied Microbiology and Biotechnology |
| 2403 | Immunology |
| 2404 | Microbiology |
| 2405 | Parasitology |
| 2406 | Virology |
| 2500 | General Materials Science |
| 2502 | Biomaterials |
| 2503 | Ceramics and Composites |
| 2504 | Electronic, Optical and Magnetic Materials |
| 2505 | Materials Chemistry |
| 2506 | Metals and Alloys |
| 2507 | Polymers and Plastics |
| 2508 | Surfaces, Coatings and Films |
| 2602 | Algebra and Number Theory |
| 2604 | Applied Mathematics |
| 2605 | Computational Mathematics |
| 2607 | Discrete Mathematics and Combinatorics |
| 2608 | Geometry and Topology |
| 2610 | Mathematical Physics |
| 2611 | Modeling and Simulation |
| 2612 | Numerical Analysis |
| 2613 | Statistics and Probability |
| 2614 | Theoretical Computer Science |
| 2702 | Anatomy |
| 2703 | Anesthesiology and Pain Medicine |
| 2704 | Biochemistry |
| 2705 | Cardiology and Cardiovascular Medicine |
| 2706 | Critical Care and Intensive Care Medicine |
| 2707 | Complementary and alternative medicine |
| 2708 | Dermatology |
| 2711 | Emergency Medicine |
| 2712 | Endocrinology, Diabetes and Metabolism |
| 2713 | Epidemiology |
| 2714 | Family Practice |
| 2715 | Gastroenterology |
| 2716 | Genetics |
| 2717 | Geriatrics and Gerontology |
| 2718 | Health Informatics |
| 2720 | Hematology |
| 2721 | Hepatology |
| 2723 | Immunology and Allergy |
| 2724 | Internal Medicine |
| 2725 | Infectious Diseases |
| 2726 | Microbiology |
| 2727 | Nephrology |
| 2728 | Neurology |
| 2729 | Obstetrics and Gynecology |
| 2730 | Oncology |
| 2731 | Ophthalmology |
| 2732 | Orthopedics and Sports Medicine |
| 2733 | Otorhinolaryngology |
| 2734 | Pathology and Forensic Medicine |
| 2735 | Pediatrics, Perinatology and Child Health |
| 2736 | Pharmacology |
| 2737 | Physiology |
| 2738 | Psychiatry and Mental health |
| 2739 | Public Health, Environmental and Occupational Health |
| 2740 | Pulmonary and Respiratory Medicine |
| 2741 | Radiology, Nuclear Medicine and Imaging |
| 2742 | Rehabilitation |
| 2743 | Reproductive Medicine |
| 2745 | Rheumatology |
| 2746 | Surgery |
| 2747 | Transplantation |
| 2748 | Urology |
| 2802 | Behavioral Neuroscience |
| 2803 | Biological Psychiatry |
| 2804 | Cellular and Molecular Neuroscience |
| 2805 | Cognitive Neuroscience |
| 2806 | Developmental Neuroscience |
| 2807 | Endocrine and Autonomic Systems |
| 2808 | Neurology |
| 2809 | Sensory Systems |
| 2910 | Issues, ethics and legal aspects |
| 2911 | Leadership and Management |
| 2916 | Nutrition and Dietetics |
| 2922 | Research and Theory |
| 3002 | Drug Discovery |
| 3003 | Pharmaceutical Science |
| 3004 | Pharmacology |
| 3005 | Toxicology |
| 3102 | Acoustics and Ultrasonics |
| 3103 | Astronomy and Astrophysics |
| 3104 | Condensed Matter Physics |
| 3105 | Instrumentation |
| 3106 | Nuclear and High Energy Physics |
| 3107 | Atomic and Molecular Physics, and Optics |
| 3108 | Radiation |
| 3109 | Statistical and Nonlinear Physics |
| 3200 | General Psychology |
| 3202 | Applied Psychology |
| 3203 | Clinical Psychology |
| 3204 | Developmental and Educational Psychology |
| 3205 | Experimental and Cognitive Psychology |
| 3206 | Neuropsychology and Physiological Psychology |
| 3207 | Social Psychology |
| 3300 | General Social Sciences |
| 3302 | Archeology |
| 3303 | Development |
| 3304 | Education |
| 3305 | Geography, Planning and Development |
| 3306 | Health |
| 3307 | Human Factors and Ergonomics |
| 3308 | Law |
| 3309 | Library and Information Sciences |
| 3310 | Linguistics and Language |
| 3311 | Safety Research |
| 3312 | Sociology and Political Science |
| 3313 | Transportation |
| 3314 | Anthropology |
| 3315 | Communication |
| 3316 | Cultural Studies |
| 3317 | Demography |
| 3318 | Gender Studies |
| 3319 | Life-span and Life-course Studies |
| 3320 | Political Science and International Relations |
| 3321 | Public Administration |
| 3322 | Urban Studies |
| 3402 | Equine |
| 3404 | Small Animals |
| 3500 | General Dentistry |
| 3504 | Oral Surgery |
| 3505 | Orthodontics |
| 3506 | Periodontics |
| 3600 | General Health Professions |
| 3603 | Complementary and Manual Therapy |
| 3604 | Emergency Medical Services |
| 3605 | Health Information Management |
| 3607 | Medical Laboratory Technology |
| 3608 | Medical Terminology |
| 3609 | Occupational Therapy |
| 3611 | Pharmacy |
| 3612 | Physical Therapy, Sports Therapy and Rehabilitation |
| 3614 | Radiological and Ultrasound Technology |
| 3616 | Speech and Hearing |

</details>

### Topics

Topics use the `T`-prefixed ID scheme — `topics: T11636` or a bare number (`11636`). There are ~4,500 topics, so browse them at <https://openalex.org/topics> or query `https://api.openalex.org/topics?per-page=200`.

## Features

- **Boolean search** — `AND`, `OR`, `NOT` with parentheses, passed directly to OpenAlex's Elasticsearch backend
- **Journal filter** — names auto-resolved to ISSNs via the OpenAlex Sources endpoint
- **Year range** — optional `year_from` / `year_to` constraints
- **Taxonomy filters** — `domains`, `fields`, `subfields`, `topics` by OpenAlex ID, as a scalar (`domains: 2`) or a list; values inside one key are OR'd, different keys AND together. Topic IDs may be bare numbers (`11636` → `T11636`). Labels are looked up and echoed at startup (`Domains: Social Sciences (2)`)
- **Result re-ranking** — results scored by title match (40%), abstract match (20%), and concept overlap (40%) after retrieval
- **Structured output** — summary table plus detail sections with DOI, citation count, FWCI, concepts (top 5, score ≥ 0.3), topics, and abstract
- **Idempotent** — re-running overwrites `out/<input>.md`

## Output

Results are written to `out/<input>.md` as a markdown table with detail sections:

```markdown
## Results — 5 paper(s) found

| # | Title | DOI | Journal | Year | Citations | Authors |
|---|---|---|---|---|---|---|

---

### 1. Paper Title

- **DOI:** `10.xxx/...`
- **Authors:** ...
- **Journal:** ...
- **Citations:** 124 | FWCI: 3.2
- **Concepts:** Climate Science (0.92), Machine Learning (0.87)
- **Topics:** Machine Learning (0.99), Climate Science (0.85)
- **Abstract:** ...
```

## License

MIT — see [LICENSE](LICENSE).
