Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Psychological Construct Definition Generator

Psychological Construct Definition Generator is a Python package for generating evidence-based ontology-style definitions of psychological constructs from PubMed and PubMed Central (PMC) literature.

Overview

The package implements a retrieval-augmented generation (RAG) workflow that searches the biomedical literature for a target psychological construct, retrieves relevant PubMed abstracts and PubMed Central (PMC) full-text articles, extracts candidate definition statements, ranks evidence using semantic similarity, and generates a concise evidence-based definition suitable for ontology development and expert curation. The APA Dictionary of Psychology is used only to verify and reference existing dictionary entries. APA content is not used to generate the literature-derived definition.

Features

  • Search PubMed for articles related to a psychological construct.
  • Retrieve full-text articles from PubMed Central (PMC), when available.
  • Retrieve PubMed abstracts as fallback evidence.
  • Extract candidate definition statements.
  • Chunk and prepare retrieved evidence for semantic retrieval.
  • Perform semantic retrieval using sentence-transformer embeddings.
  • Rank evidence passages by semantic relevance.
  • Generate ontology-style definitions.
  • Verify APA Dictionary entries and provide the official reference URL when available.
  • Export definitions and supporting evidence as Markdown.

Installation

pip install psych-defgen
playwright install chromium

Verify Installation

python -c "import psych_defgen; print('Package installed successfully')"

Development Installation

To install development version from GitHub:

git clone https://github.com/uflcod/psych-defgen.git
cd psych-defgen

pip install -e .
playwright install chromium

Editable installation allows you to make changes to the source code and use them immediately without reinstalling the package.


Configure NCBI Credentials

This package uses the NCBI Entrez API to retrieve PubMed and PubMed Central articles. An NCBI email address is required to access the NCBI Entrez API. You can provide your credentials either through environment variables or as command-line arguments.

Option 1: Environment variables (recommended)

macOS / Linux

export NCBI_EMAIL="YOUR_NCBI_EMAIL"

Windows PowerShell

$env:NCBI_EMAIL="YOUR_NCBI_EMAIL"

Replace YOUR_NCBI_EMAIL with your own email address.

For higher request limits, you may optionally configure an NCBI API key.

macOS / Linux

export NCBI_API_KEY="YOUR_API_KEY"

Windows PowerShell

$env:NCBI_API_KEY="YOUR_API_KEY"

If no API key is provided, the package uses the standard NCBI request limits.

Option 2: Command-line arguments

Instead of environment variables, you can provide your NCBI email directly when running the program:

psych-defgen loneliness \
    --email YOUR_NCBI_EMAIL

To also use an NCBI API key:

psych-defgen loneliness \
    --email YOUR_NCBI_EMAIL \
    --api-key YOUR_API_KEY

If both environment variables and command-line arguments are provided, the command-line arguments take precedence.

Note

The package does not store or transmit your email address or API key except when making requests to the official NCBI Entrez API. These credentials are used only to identify your requests in accordance with NCBI API guidelines.


Usage

Generate a definition for a psychological construct:

psych-defgen loneliness

Alternatively, specify your NCBI email directly:

psych-defgen loneliness \
    --email YOUR_NCBI_EMAIL

Multi-word constructs are supported:

psych-defgen "social vulnerability"

Specify the number of retrieved articles and evidence passages:

psych-defgen loneliness \
    --max-results 20 \
    --top-k 5

Specify a custom output file:

psych-defgen loneliness \
    --output results/loneliness_definition.md

The NCBI email can be combined with other options:

psych-defgen loneliness \
    --email YOUR_NCBI_EMAIL \
    --max-results 20 \
    --top-k 5 \
    --output results/loneliness_definition.md

Display all available command-line options:

psych-defgen --help

Output

By default, generated definitions are saved as Markdown files in the outputs directory. A custom output file can be specified using the --output option.

outputs/loneliness_definition.md

The output filename is automatically generated from the requested psychological construct.


Requirements

  • Python 3.11+
  • Valid NCBI email address
  • Chromium browser installed thorugh Playwright

Install the required Playwright browser with

playwright install chromium

An NCBI API key is optional but recommended for higher request rate limits.


License

This project is licensed under the MIT License.

Citation

Citation information will be provided upon publication of the accompanying manuscript.

Release files for psych-defgen 0.0.1a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for psych-defgen 0.0.1a1
File Size Uploaded
psych_defgen-0.0.1a1.tar.gz 14.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for psych-defgen 0.0.1a1
File Interpreter ABI Platform
psych_defgen-0.0.1a1-py3-none-any.whl Python 3 none any Details

Total release size: 35.6 kB

Release files / psych_defgen-0.0.1a1.tar.gz

Download URL psych_defgen-0.0.1a1.tar.gz
Size 14.9 kB
Tags Source
SHA-256 checksum
How to use checksums
6fb2cabc0d78df64e9cb5a6391409350424bbfcb133281bf6d79059af6f7a7c3
BLAKE2b-256 checksum
How to use checksums
f4ffb9d29bdfa1b4f566f7fe8d7f22f3b9b707bd12a9a917a0c8679decae7f06
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / psych_defgen-0.0.1a1-py3-none-any.whl

Download URL psych_defgen-0.0.1a1-py3-none-any.whl
Size 20.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5d633855c3b4569f57ba9f65f59cec0b5ee9a79a3ef27329d38076a76ef31819
BLAKE2b-256 checksum
How to use checksums
df4dadbdc9a5bb44495f26ec53bcb14889233f237d119396997348d12d6092d9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.24 {"installer":{"name":"uv","version":"0.11.24","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

This release

0.0.1a1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page