Skip to content

Commit

Permalink
Merge pull request #1 from MarkNenadov/master
Browse files Browse the repository at this point in the history
Port to Python 3.x (Without breaking Python 2.x suport)
  • Loading branch information
Jonathan Feinberg committed Jul 26, 2013
2 parents d0b84e7 + 25226d0 commit c78feea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions haikufinder/__init__.py
Expand Up @@ -38,7 +38,7 @@
from __future__ import with_statement from __future__ import with_statement
import nltk import nltk
import re import re
import cPickle as pickle import pickle
import gzip import gzip
import os.path import os.path
import sys import sys
Expand Down Expand Up @@ -70,7 +70,7 @@ def read_alternates(which):
with open(file('cmudict/cmudict.pickle'), 'rb') as p: with open(file('cmudict/cmudict.pickle'), 'rb') as p:
syllables = pickle.load(p) syllables = pickle.load(p)
with open(file('cmudict/custom.dict'), 'r') as p: with open(file('cmudict/custom.dict'), 'r') as p:
for line in p.xreadlines(): for line in p.readlines():
(word, count) = line.split() (word, count) = line.split()
syllables[word] = int(count) syllables[word] = int(count)


Expand Down Expand Up @@ -190,10 +190,10 @@ def count_syllables(self):
for word in self.words: for word in self.words:
syllable_count += self._count_syllables(self.clean(word)) syllable_count += self._count_syllables(self.clean(word))
except KeyError: except KeyError:
print "I don't know '%s'"%word print("I don't know '%s'"%word)
return -1 return -1
except Nope: except Nope:
print "I can't do '%s'"%word print("I can't do '%s'"%word)
return -1 return -1
return syllable_count return syllable_count


Expand Down
8 changes: 4 additions & 4 deletions scripts/findhaikus
Expand Up @@ -35,7 +35,7 @@ try:
except: except:
text = sys.stdin.read() text = sys.stdin.read()
for haiku in HaikuFinder(text).find_haikus(): for haiku in HaikuFinder(text).find_haikus():
print haiku[0] print(haiku[0])
print " %s" % haiku[1] print(" %s" % haiku[1])
print haiku[2] print(haiku[2])
print print()

0 comments on commit c78feea

Please sign in to comment.