Skip to main content

Python package for Word Sentence Disambiguation (WSD) using GlossBERT model and NLTK WordNet.

Project description

GlossBERT Wrapper Class

PyPI Version Python Versions License Publish Python 🐍 distribution 📦 to PyPI

This Python package provides a convenient wrapper for using GlossBERT, allowing you to easily perform word sense disambiguation (WSD) by searching WordNet through NLTK.

The source code in this repository is adapted from this script from the original GlossBERT project.

Features

  • Simplifies the use of GlossBERT for WSD tasks.
  • Provides integration with WordNet via NLTK.

Installation

Install the package using pip:

pip install glossbert

Alternatively, install directly from the GitHub repository:

pip install git+https://github.com/cruzlorite/glossbert.git

Usage

Here is an example of how to use the GlossBERT class:

>>> from glossbert import GlossBERT
>>> 
>>> # initialize the GlossBERT instance
>>> gloss = GlossBERT()
>>> 
>>> # define a sentence and specify the target word
>>> sent = "I love dogs!"
>>> start_idx, end_idx, target_word = 7, 11, "dog"
>>> 
>>> # perform word sense disambiguation
>>> gloss(sent, start_idx, end_idx, target_word)
[
    (0.9973864, Synset('dog.n.01')),
    (0.025929835, Synset('frank.n.02')),
    (0.0030947044, Synset('dog.n.03')),
    (0.0024504508, Synset('cad.n.01')),
    (0.001387376, Synset('andiron.n.01')),
    (0.00057538506, Synset('pawl.n.01')),
    (0.0005529578, Synset('chase.v.01')),
    (0.00046094437, Synset('frump.n.01'))
]

License

This project is licensed under the MIT License, consistent with the original GlossBERT project.

Acknowledgements

Special thanks to the authors of the original GlossBERT for their foundational work.

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

glossbert-1.0.6.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

glossbert-1.0.6-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file glossbert-1.0.6.tar.gz.

File metadata

  • Download URL: glossbert-1.0.6.tar.gz
  • Upload date:
  • Size: 7.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for glossbert-1.0.6.tar.gz
Algorithm Hash digest
SHA256 74598bf8a4632e30f5fc9b26180a65672e479294c6a9ae249f551c43335b2da7
MD5 9aaee8c2ab7c0ec236ad26efbc1c4ed2
BLAKE2b-256 054b6e15c771a45f0dd38e4dcda3871aa58299e9efbb1b9ed3503467a10322c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for glossbert-1.0.6.tar.gz:

Publisher: publish-pypi.yaml on cruzlorite/glossbert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file glossbert-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: glossbert-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for glossbert-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 97e084e04b2c2487287f5a3b992604c9ad2eaad09ebdcb8673b5ccc1786150ce
MD5 becb334b43e9bd7f13044b9dae9e3f92
BLAKE2b-256 6b4e50556b6ee2be0b348609d4c203622730f4a9d4fc6432ecf8d73857dba3d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for glossbert-1.0.6-py3-none-any.whl:

Publisher: publish-pypi.yaml on cruzlorite/glossbert

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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