stoichiograph

Spell words with elemental symbols from the periodic table.
git clone git://git.amin.space/stoichiograph.git
Log | Files | Refs | LICENSE

commit 8930bdee2e7de948cd34438370fb67527ae92afa
parent 1d9ca57e5cdfaa5cc1915b44032fe3d2f4017484
Author: amin <dev@aminmesbah.com>
Date:   Thu, 27 Apr 2017 18:31:53 +0000

Clarify comments.

FossilOrigin-Name: d506e72ef0445b437aff691129da13bf09ce9e98e282d93f237b40569c320e49
Diffstat:
Mspeller.py | 10+++++-----
Mstoichiograph.py | 1+
2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/speller.py b/speller.py @@ -34,13 +34,13 @@ def spell(word, symbols=ELEMENTS): """ log.info('Word: {}'.format(word)) - log.debug('Using graph speller') g = Graph() build_spelling_graph(word, g) elemental_spellings = sorted( [ tuple(node.value.capitalize() for node in path) + # There will only ever be at most 2 firsts and 2 lasts. for first in g.firsts() for last in g.lasts() for path in find_all_paths(g._children_of, first, last) @@ -129,13 +129,13 @@ class Graph(): return export.getvalue() -# A single node of the graph. +# A single node of the graph. A glyph and its position in the word. Node = namedtuple('Node', ['value', 'position']) def build_spelling_graph(word, graph, symbols=ELEMENTS): """Given a word and a graph, find all single and double-character - tokens in the word. Add them to the graph only if they are present + glyphs in the word. Add them to the graph only if they are present within the given set of allowed symbols. """ @@ -143,8 +143,8 @@ def build_spelling_graph(word, graph, symbols=ELEMENTS): """Pop the single and double-character roots off the front of a given string, then recurse into what remains. - For the word 'because', the roots and remainders look something - like: + For the word 'because', the roots and remainders for each call + look something like: 'b' 'ecause' 'e' 'cause' diff --git a/stoichiograph.py b/stoichiograph.py @@ -109,6 +109,7 @@ def main(): with words_file.open('r') as f: dictionary = f.readlines() + # TODO(amin): Handle punctuation, apostraphies, etc. words = [word.rstrip('\n') for word in dictionary if "'" not in word] else: words = args.words