Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
D
dict-trie
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jeroen F.J. Laros
dict-trie
Commits
f5b13da5
Commit
f5b13da5
authored
Mar 25, 2018
by
Jeroen F.J. Laros
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Updated documentation.
parent
53880f20
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
dict_trie/dict_trie.py
dict_trie/dict_trie.py
+9
-9
No files found.
dict_trie/dict_trie.py
View file @
f5b13da5
...
...
@@ -2,7 +2,7 @@ import itertools
def
_add
(
root
,
word
):
"""Add a word to
the
trie.
"""Add a word to
a
trie.
:arg dict root: Root of the trie.
:arg str word: A word.
...
...
@@ -18,7 +18,7 @@ def _add(root, word):
def
_find
(
root
,
word
):
"""Find the node after following the path in
the
trie given by {word}.
"""Find the node after following the path in
a
trie given by {word}.
:arg dict root: Root of the trie.
:arg str word: A word.
...
...
@@ -67,7 +67,7 @@ def _iterate(path, node):
:arg str path: Path taken so far to reach the current node.
:arg dict node: Current node.
:returns iter: All words in
the
trie.
:returns iter: All words in
a
trie.
"""
if
''
in
node
:
yield
path
...
...
@@ -97,7 +97,7 @@ def _fill(node, alphabet, length):
def
_hamming
(
path
,
node
,
word
,
distance
,
cigar
):
"""Find all paths in
the
trie that are within a certain hamming distance of
"""Find all paths in
a
trie that are within a certain hamming distance of
{word}.
:arg str path: Path taken so far to reach the current node.
...
...
@@ -105,7 +105,7 @@ def _hamming(path, node, word, distance, cigar):
:arg str word: Query word.
:arg int distance: Amount of allowed errors.
:returns iter: All word in
the
trie that have Hamming distance of at most
:returns iter: All word in
a
trie that have Hamming distance of at most
{distance} to {word}.
"""
if
distance
<
0
:
...
...
@@ -130,7 +130,7 @@ def _hamming(path, node, word, distance, cigar):
def
_levenshtein
(
path
,
node
,
word
,
distance
,
cigar
):
"""Find all paths in
the
trie that are within a certain Levenshtein
"""Find all paths in
a
trie that are within a certain Levenshtein
distance of {word}.
:arg str path: Path taken so far to reach the current node.
...
...
@@ -138,7 +138,7 @@ def _levenshtein(path, node, word, distance, cigar):
:arg str word: Query word.
:arg int distance: Amount of allowed errors.
:returns iter: All word in
the
trie that have Hamming distance of at most
:returns iter: All word in
a
trie that have Hamming distance of at most
{distance} to {word}.
"""
if
distance
<
0
:
...
...
@@ -219,7 +219,7 @@ class Trie(object):
return
''
def
best_hamming
(
self
,
word
,
distance
):
"""Find the best match with {word} in
the
trie.
"""Find the best match with {word} in
a
trie.
:arg str word: Query word.
:arg int distance: Maximum allowed distance.
...
...
@@ -252,7 +252,7 @@ class Trie(object):
return
''
def
best_levenshtein
(
self
,
word
,
distance
):
"""Find the best match with {word} in
the
trie.
"""Find the best match with {word} in
a
trie.
:arg str word: Query word.
:arg int distance: Maximum allowed distance.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment