Skip to main content

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


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.6.tar.gz (2.3 kB view details)

Uploaded Source

Built Distribution

wordpredict-0.1.6-py3-none-any.whl (2.9 kB view details)

Uploaded Python 3

File details

Details for the file wordpredict-0.1.6.tar.gz.

File metadata

  • Download URL: wordpredict-0.1.6.tar.gz
  • Upload date:
  • Size: 2.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Linux/6.2.0-1012-azure

File hashes

Hashes for wordpredict-0.1.6.tar.gz
Algorithm Hash digest
SHA256 d6b90dce6ad299c8df75e5849a56d8cf231f75770b342acbd3410776669324aa
MD5 219d5f8fe78e152c4a5c6b295aada70e
BLAKE2b-256 b664d7108af7b584fdceb745da07caa167050beb9f2fbe3a12e1c3352bb1b5eb

See more details on using hashes here.

File details

Details for the file wordpredict-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: wordpredict-0.1.6-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.11.5 Linux/6.2.0-1012-azure

File hashes

Hashes for wordpredict-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 1b59e95e161d398ae44a9daa14dcbc8b3e96b7d01dc0ddd77e09bc0ef35bda72
MD5 fef8a288cfe99dc6dc166bafe5fcd925
BLAKE2b-256 39e4de0945459ec9fa350cb74c130520f35c6767a3efb4c8bc828c7512eb4679

See more details on using hashes here.

Supported by

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