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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file stsmd-0.0.6.tar.gz.

File metadata

  • Download URL: stsmd-0.0.6.tar.gz
  • Upload date:
  • Size: 2.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

File hashes

Hashes for stsmd-0.0.6.tar.gz
Algorithm Hash digest
SHA256 0aaa189f9cf49523a9f43820397f3b6cb11e0a7d354ed6fe197553711fa20fd2
MD5 a0e7700d459c38c30d9b653c13b0d6c1
BLAKE2b-256 3387cd0fd6e069e5976010e90de464d4c32bdc2c5c5c96c4fc9896efb96aad2c

See more details on using hashes here.

File details

Details for the file stsmd-0.0.6-py3-none-any.whl.

File metadata

  • Download URL: stsmd-0.0.6-py3-none-any.whl
  • Upload date:
  • Size: 3.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.24.0 setuptools/40.8.0 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.7.3

File hashes

Hashes for stsmd-0.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 16a6a48115a93f346be248b4125febae9c81c3e3eb04d8e93b43363dfa9f6632
MD5 1099d1ceb70d6c248ec24e2c3a8494d2
BLAKE2b-256 b86bf1398d51a01e16abfdf9c25a185e3eb90e0d3c6e83de110874c779664d76

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