Skip to main content

Unofficial Python wrapper for the NCBI LitSense API

Project description

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pylitsense-0.1.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

pylitsense-0.1.0-py3-none-any.whl (4.7 kB view details)

Uploaded Python 3

File details

Details for the file pylitsense-0.1.0.tar.gz.

File metadata

  • Download URL: pylitsense-0.1.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pylitsense-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dc9b64465de44cc4aec4d00a9ea526b5a60373ab80b609498bc7e78a52fb7786
MD5 f9bee7ff73c44834319763c384d4fd51
BLAKE2b-256 1d8f5c41104782ec013c7b2baf479906dfed598872d26a10f9126c81602820c9

See more details on using hashes here.

File details

Details for the file pylitsense-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pylitsense-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.18

File hashes

Hashes for pylitsense-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 5dd50890ff7590b7a7463bda293911e1c4ca741038da52a4b0eba26c652caadb
MD5 964c6f51c91739fdd69591aee43c8361
BLAKE2b-256 fba3e94e4fa493a905c621b3e10c001e458dfd4303da0e058f66116f8d9c1bb1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page