Hi, I got the following results when I call main.sh. But I only want to main $1 as a token, but not "go,", "yet.", etc. Does anybody know how to maintain things like "$1" but tokenize ".", "," and "!", etc.?
~$ ./main.sh
['Eighty-seven', 'miles', 'to', 'go,', 'yet.', '$1', 'Onward!']
==> main.py <==
#!/usr/bin/env python
# vim: set noexpandtab tabstop=2 shiftwidth=2 softtabstop=-1 fileencoding=utf-8:
from nltk.tokenize import RegexpTokenizer
import sys
tokenizer = RegexpTokenizer(r'\S+')
print tokenizer.tokenize(''.join(sys.stdin.readlines()))
==> main.sh <==
#!/usr/bin/env bash
# vim: set noexpandtab tabstop=2:
echo 'Eighty-seven miles to go, yet. $1 Onward!' | ./main.py