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


Release history Release notifications

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 hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page