Skip to main content

pylitsense

build

The pylitsense package is an unofficial Python wrapper for the NCBI LitSense API. It allows you to query the LitSense API and get back a list of LitSenseResult objects, which contain the text of relevant sentences and a score of their similarity to your query.

NCBI describes LitSense as follows:

LitSense is a unique search system for making sense of the biomedical literature at the sentence level, providing a unified access to over half a billion statements extracted from PubMed and PubMed Central.

Given a query, LitSense finds the best-matching sentences based on overlapping terms as well as semantic similarity via a cutting-edge neural embedding approach.

For example, given this query:

"Breast cancers with HER2 amplification"

You will receive an array of results, each with a score of how relevant it is to your query, like this:

[
    LitSenseResult(
        text='HER2 amplification/overexpression accounts for aggressive clinical features of HER2 positive breast cancer.', 
        score=0.9443494081497192, 
        annotations=[
            '79|4|gene|2064', 
            '93|13|disease|MESH:D001943', 
            '0|4|gene|2064'
        ],
        pmid=28800870,
        pmcid=None,
        section='abstract'
    ), 
    ...
]

Installation

pip install pylitsense

Usage

from pylitsense.pylitsense import PyLitSense

# Initialize
pls = PyLitSense()

# Query
results = pls.query("your query here")

# Print results
for result in results:
    print(result.text, result.score)

Parameters

  • query_str (str): The query string for the API.
  • rerank (bool, optional): Whether to rerank the results. Defaults to True. It seems that this refers to reranking using "semantic vectors" (embeddings).
  • limit (int, optional): Limit the number of results. Defaults to None (no limit).
  • min_score (float, optional): Minimum score threshold for results. Defaults to None (no minimum score).

Limitations

The LitSense API itself has the following limitations:

  • Maximum of 100 results per query
  • Rate limit of one request per user per second

In addition, this package is:

  • Only tested on Python 3.9, 3.10, and 3.11

Release files for pylitsense 0.1.0

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

Source distribution (sdist)

Source distribution for pylitsense 0.1.0
File Size Uploaded
pylitsense-0.1.0.tar.gz 4.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylitsense 0.1.0
File Interpreter ABI Platform
pylitsense-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 8.7 kB

Release files / pylitsense-0.1.0.tar.gz

Download URL pylitsense-0.1.0.tar.gz
Size 4.0 kB
Tags Source
SHA-256 checksum
How to use checksums
dc9b64465de44cc4aec4d00a9ea526b5a60373ab80b609498bc7e78a52fb7786
BLAKE2b-256 checksum
How to use checksums
1d8f5c41104782ec013c7b2baf479906dfed598872d26a10f9126c81602820c9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release files / pylitsense-0.1.0-py3-none-any.whl

Download URL pylitsense-0.1.0-py3-none-any.whl
Size 4.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5dd50890ff7590b7a7463bda293911e1c4ca741038da52a4b0eba26c652caadb
BLAKE2b-256 checksum
How to use checksums
fba3e94e4fa493a905c621b3e10c001e458dfd4303da0e058f66116f8d9c1bb1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.18

Release history Release notifications | RSS feed

This release

0.1.0 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