Skip to content

Commit

Permalink
Remove node iterator for now. Need a better iterator
Browse files Browse the repository at this point in the history
  • Loading branch information
Abhishek Singh committed Oct 27, 2017
1 parent a7c8761 commit 0e98c99
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![Logo](https://github.com/aosingh/lexpy/blob/master/images/lexpylogo.png)

[![Travis](https://travis-ci.org/aosingh/lexpy.svg?branch=master)]()
[![Travis](https://travis-ci.org/aosingh/lexpy.svg?branch=master)](https://travis-ci.org/aosingh/lexpy)
[![Coverage Status](https://coveralls.io/repos/github/aosingh/lexpy/badge.svg?branch=master)](https://coveralls.io/github/aosingh/lexpy?branch=master)
[![Maintainability](https://api.codeclimate.com/v1/badges/60626f81c0db0c5d8dcd/maintainability)](https://codeclimate.com/github/aosingh/lexpy/maintainability)

Expand Down Expand Up @@ -76,7 +76,6 @@ dawg.reduce() # Perform DFA minimization. Call this every time a chunk of words
len(dawg) # Number of nodes in DAWG
13


```


Expand Down
4 changes: 3 additions & 1 deletion lexpy/_base/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ def __getitem__(self, letter):
"""
return self.children[letter]

'''
def __iter__(self):
"""
Description:
Expand All @@ -52,6 +53,7 @@ def __iter__(self):
current_node = queue.popleft()
yield current_node
queue.extend([child for _, child in current_node.children.iteritems()])
'''

def __str__(self):
"""
Expand Down Expand Up @@ -94,7 +96,7 @@ def __hash__(self):
def __repr__(self):
"""
Description:
Returns a nicely formatted string of the FSA node. This is invoked when `print()` is called.
Returns a nicely formatted string of the FSA node. This is invoked when `repr()` is called.
:return:
"""
return "{0}(id={1}, label={2}, EOW={3})".format(self.__class__.__name__, self.id, self.val, self.eow)
8 changes: 8 additions & 0 deletions lexpy/tests/test_dawg.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ def test_dawg_node_count(self):
self.assertEqual(2, self.dawg.get_word_count(), "Word count not equal")
self.assertEqual(7, len(self.dawg), "Number of nodes")

def test_dawg_reduced_node_count(self):
self.dawg = DAWG()
self.dawg.add_all(["tap", "taps", "top", "tops"])
self.dawg.reduce()
self.assertEqual(5, len(self.dawg), "Number of nodes")


class TestDAWGPrefixExists(unittest.TestCase):
def test_dawg_node_prefix_exists(self):
Expand Down Expand Up @@ -215,5 +221,7 @@ def test_dawg_build_from_file_object(self):
self.assertTrue('ZYGOMORPHY' in self.dawg, "Word should be in dawg")
self.assertEqual(178691, self.dawg.get_word_count(), "Word count not equal")



if __name__ == '__main__':
unittest.main()

0 comments on commit 0e98c99

Please sign in to comment.