Skip to content

Commit

Permalink
Fix error in wordcount example
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnVinyard committed Mar 7, 2019
1 parent cdbac60 commit 7731487
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Tokenizer(ff.Node):
self._pattern = re.compile('(?P<word>[a-zA-Z]+)\W+')

def _enqueue(self, data, pusher):
self._cache += data
self._cache += data.decode()

def _dequeue(self):
matches = list(self._pattern.finditer(self._cache))
Expand Down
12 changes: 10 additions & 2 deletions examples/wordcount.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ def __init__(self, needs=None):
self._pattern = re.compile('(?P<word>[a-zA-Z]+)\W+')

def _enqueue(self, data, pusher):
self._cache += data
self._cache += data.decode()

def _dequeue(self):
matches = list(self._pattern.finditer(self._cache))
Expand Down Expand Up @@ -123,8 +123,16 @@ def summarize_corpus(corpus):
n=corpus.total_counts.get("the", 0))


example = '''example:
python wordcount.py \\
--url http://textfiles.com/food/1st_aid.txt \\
--url http://textfiles.com/food/antibiot.txt \\
'''

if __name__ == '__main__':
parser = argparse.ArgumentParser()

parser = argparse.ArgumentParser(epilog=example, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument(
'--url',
help='specify one or more urls of text files to ingest',
Expand Down

0 comments on commit 7731487

Please sign in to comment.