Skip to main content

A small package to get closest text document with SMD and Sentence transformers embeddings

Project description

Sentence Mover's Distance using Sentence Transformers Package

Calculates Sentence Mover's Distance using Fast Word Mover's Distance and the embeddings provided by Sentence Transformers.

Installation

Before installing the package, check that you have already installed :

Numpy

Sentence Transformers

wmd

[NLTK] (https://pypi.org/project/nltk/)

Then

pip install stsmd

Tested on Linux and macOS.

Usage

You must have the document you want to find the closest document as a string and the other documents as a list of strings.

from stsmd import SMD

calc = SMD("Politician speaks to the media in Illinois.", ["The president greets the press in Chicago.", "The President delivers his inaugural address."])

print(calc.get_closest())

This returns the number of the nearest document and its distance.

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

stsmd-0.0.6.tar.gz (2.6 kB view hashes)

Uploaded Source

Built Distribution

stsmd-0.0.6-py3-none-any.whl (3.6 kB view hashes)

Uploaded Python 3

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