Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closing out several small problems #5

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions README.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
Installer: http://MrFeinberg.com/haikufinder-1.1.zip
Files: http://MrFeinberg.com/haikufinder-1.1.zip or use github repo.

*
* REQUIRES NLTK, THE NATURAL LANGUAGE TOOLKIT
* http://www.nltk.org/download
*
Installation requires NLTK and its punkt package. First-time steps
Unzip main file.
pip install nltk
python
import nltk
nltk.download('punkt')
exit()
python setup.py install

A script to begin processing is located in \scripts

A Python hack to find "haikus" in English text. For the purposes of this
module, a "haiku" is one or more complete sentences that, together, can be
broken into groups of 5, 7, and 5 syllables. Each canididate haiku line,
broken into groups of 5, 7, and 5 syllables. Each candidate haiku line,
and then the entire haiku, has to make it through a few heuristics to
filter out constructions that are likely to scan awkwardly (like verb
phrases split across lines). Since this code doesn't really try to
Expand Down
4 changes: 2 additions & 2 deletions haikufinder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def read_alternates(which):
syllables = pickle.load(p)
with open(file('cmudict/custom.dict'), 'r') as p:
for line in p.readlines():
if not len(line):
continue
if not len(line):
continue
(word, count) = line.split()
syllables[word] = int(count)

Expand Down
2 changes: 1 addition & 1 deletion scripts/findhaikus → scripts/findhaikus.py
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
text = open(sys.argv[1], "r").read()
except:
text = sys.stdin.read()
for haiku in HaikuFinder(text.decode('utf-8')).find_haikus():
for haiku in HaikuFinder(unicode(text, errors='replace')).find_haikus():
print(haiku[0])
print(" %s" % haiku[1])
print(haiku[2])
Expand Down