Permalink
Browse files

Reading file directly

  • Loading branch information...
Sergio Grau Puerto
Sergio Grau Puerto committed Sep 12, 2012
1 parent 45c51f6 commit b43f9646e7595e1565a301e5478ccc2ef1ae1161
Showing with 2 additions and 2 deletions.
  1. +2 −2 keywords/keywords.py
View
@@ -17,8 +17,8 @@ def keywords_and_ngrams(input, nKeywords=100, thresholdLL=19, nBigrams=25, thres
fdistText = defaultdict(int)
sumText = 0
listWords = []
-
listSentences = []
+
if isinstance(input,str):
listSentences = [input]
else:
@@ -73,6 +73,6 @@ def keywords_and_ngrams(input, nKeywords=100, thresholdLL=19, nBigrams=25, thres
if len(sys.argv) < 2:
sys.stderr.write("Usage: python %s <text.txt>\n" % (sys.argv[0],))
else:
- d = keywords_and_ngrams(open(os.path.join(os.path.dirname(__file__), sys.argv[1]),"r").readlines(), 100, 19, 25, 2)
+ d = keywords_and_ngrams(open(sys.argv[1]),"r").readlines(), 100, 19, 25, 2)
print json.dumps(d)

0 comments on commit b43f964

Please sign in to comment.