wordpredict
This is a library that predicts words for ambiguous input.
Installation
pip install wordpredict
How to use
code
import pandas as pd
from wordpredict import WordPredict
corpus = pd.read_csv(
"./unigram_freq.csv",
header=0,
keep_default_na=False,
).values
wp = WordPredict(corpus[:, 0], corpus[:, 1])
print("start user input")
input = ["e", "f", "g", "h"]
print(wp.update(input))
input = ["e", "f", "g", "h"]
print(wp.update(input))
input = ["i", "j", "k", "l"]
print(wp.update(input))
print("reset user input")
wp.reset()
input = ["e", "f", "g", "h"]
print(wp.update(input))
input = ["m", "n", "o", "p"]
print(wp.update(input))
output
start user input
['for', 'e', 'from', 'he', 'has', 'have']
['he', 'get', 'here', 'her', 'help', 'few']
['help', 'held', 'felt', 'hell', 'hello', 'helps']
reset user input
['for', 'e', 'from', 'he', 'has', 'have']
['for', 'home', 'go', 'how', 'good', 'end']
corpus
e.g., https://www.kaggle.com/datasets/rtatman/english-word-frequency
execution time
%%timeit
import pandas as pd
from wordpredict import WordPredict
corpus = pd.read_csv(
"./unigram_freq.csv",
header=0,
keep_default_na=False,
).values
wp = WordPredict(corpus[:, 0], corpus[:, 1])
1.42 s ± 83.7 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)
%%timeit
input = ["e", "f", "g", "h"]
wp.update(input)
input = ["e", "f", "g", "h"]
wp.update(input)
input = ["i", "j", "k", "l"]
wp.update(input)
8.34 ms ± 315 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)
note
autocomple was implemented with reference to https://doi.org/10.1145/3173574.3173755
Metadata
Release files for wordpredict 0.2.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| wordpredict-0.2.3.tar.gz | 2.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wordpredict-0.2.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 5.7 kB
Release files / wordpredict-0.2.3.tar.gz
| Download URL | wordpredict-0.2.3.tar.gz |
|---|---|
| Size | 2.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
43b49b0d921b67ed821fdf384f426221ba0315cd90727e3e4c9e45875ab787ad
|
|
BLAKE2b-256 checksum How to use checksums |
67a676b18178c2b75be22f3ec5fd9d166d48c30560c3db38f227da20cb5e969e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.0 Linux/6.2.0-1016-azure
|
Release files / wordpredict-0.2.3-py3-none-any.whl
| Download URL | wordpredict-0.2.3-py3-none-any.whl |
|---|---|
| Size | 3.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e1a7aec1cfd578c56ddcc99dd96cf2eefd74567a9ad38dd852b9c9cc223ddbd0
|
|
BLAKE2b-256 checksum How to use checksums |
24781faeb90f509bdd94c085567df38cfbe08084a34f56e2d37edc6f274b267e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.7.1 CPython/3.12.0 Linux/6.2.0-1016-azure
|