Skip to main content

Manage Word Substitutions

Project description

### WordSub

#### Install
`pip install word-sub`

#### Build
```python setup.py sdist```

```twine upload dist/*```

#### Usage
```python
from word_sub import WordMappings

# Init a WordMappings Class

# NLTK and gensim Stopwords are available by default
wm = WordMappings()

# Override this with
wm = WordMappings(stopwords=False)

# Token substitution is implemented via __call__
>>> wm('the dish ran away with the spoon'.split())
['dish', 'ran', 'away', 'spoon'] # Stopwords removed

# Add additional stopwords
>>> wm.add_pair(None, ['ran'])
>>> wm('the dish ran away with the spoon'.split())
['dish', 'away', 'spoon']

# Token substitution
>>> wm.add_pair('senior', ['sr', 'lead', 'head'])
>>> wm('lead manager'.split())
['senior', 'manager']

# Save and load via .save and .load

```

Project details


Download files

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

Files for word-sub, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size word-sub-0.0.4.tar.gz (4.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page