Skip to main content

A trie filled with words from several languages (English - en, German - de , French - fr, Spanish - es, Portuguese - pt)

Project description

WordTriePy

This is a small Python package that implements a trie filled with words from several languages (English - en, German - de , French - fr, Spanish - es, Portuguese - pt) implemented as nested dictionaries.

Install

pip install wordtriepy

Usage

To find all characters that could follow the partial word "chair" in the English language, use the get_next_chars() method:

from wordtriepy import WordTrie

t = WordTrie()
print(t.get_next_chars("chair"))
# outputs: ['_end', 'b', 'e', '-', 'i', 'l', 'm', 'p', 's', 'w']

The _end token tells us that "chair" itself is a valid word and there are 4 other characters ('b', 'e', '-', 'i', 'l', 'm', 'p', 's', 'w') that could follow the word "chair" in the English language that could form new valid words.

To get a list of words that can be formed by the partial word "salz" in the German language, use the get_next_words() method:

from wordtriepy import WordTrie

t = WordTrie(language="de")
print(t.get_next_words("salz", topn=5))
# outputs: ['salz', 'salze', 'salzt', 'salzen', 'salzes']

This returns the top 5 words after a breadth-first-search in the German word trie.

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

wordtriepy-0.0.3.tar.gz (6.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

wordtriepy-0.0.3-py3-none-any.whl (7.6 MB view details)

Uploaded Python 3

File details

Details for the file wordtriepy-0.0.3.tar.gz.

File metadata

  • Download URL: wordtriepy-0.0.3.tar.gz
  • Upload date:
  • Size: 6.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.0

File hashes

Hashes for wordtriepy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 0d4ba16a50001a11138fd7c2544ca50d3271ea29dee7a564139265d0999e0261
MD5 c5ce54412c19049b91606d8cb87ba3ac
BLAKE2b-256 5c8fe4ee86290d69c87ebbb355aff6c6f9cb8492d0453bd69202410cd62b909e

See more details on using hashes here.

File details

Details for the file wordtriepy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: wordtriepy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 7.6 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.10.0

File hashes

Hashes for wordtriepy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 092768e8e3c439d3a3dc4c18f5825b1bd7afe74ff70b22602fa850cd115f02aa
MD5 640add29b095899db46c75962a0d707f
BLAKE2b-256 11ed8807da40962fe6fc9ed95c2ebbd9651a636e4022f358310f1f99989c15ca

See more details on using hashes here.

Supported by

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