word predictor
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
wordpredict-0.1.4.tar.gz
(2.3 kB
view details)
Built Distribution
File details
Details for the file wordpredict-0.1.4.tar.gz
.
File metadata
- Download URL: wordpredict-0.1.4.tar.gz
- Upload date:
- Size: 2.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.13 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 52b6c400865d260d4bad98f19883ea0b81f446937868824006994f85e25ae2fe |
|
MD5 | 5c3edeae2fa7e16cec318ba7299fab58 |
|
BLAKE2b-256 | 9e4e36959147c3eed835fd5ec0e847a4603883d8832b728e8125f132e2254b8a |
File details
Details for the file wordpredict-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: wordpredict-0.1.4-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.6.1 CPython/3.8.13 Darwin/22.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 557db5e89fceb20bd5558e0f5d8e9a391a14bbfb0f7cbcb256ddb9a860c0fea8 |
|
MD5 | e2a14c87f6b8492a7390a039ffe96b98 |
|
BLAKE2b-256 | 4ace080212599ed42e78d580b1a34635e2bdfc06896c17eb97e592f4c44005b1 |