From 77b442fa88d3c8a0c7d3035376e2d7121aa199f9 Mon Sep 17 00:00:00 2001 From: keroro520 Date: Fri, 12 Sep 2014 13:42:05 +0800 Subject: [PATCH] fix issues (https://github.com/fxsjy/jieba/issues/125) --- jieba/analyse/__init__.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jieba/analyse/__init__.py b/jieba/analyse/__init__.py index 2c6a04b..96fa552 100755 --- a/jieba/analyse/__init__.py +++ b/jieba/analyse/__init__.py @@ -26,6 +26,8 @@ def get_idf(abs_path): content = open(abs_path,'rb').read().decode('utf-8') idf_freq = {} lines = content.split('\n') + if lines and not lines[-1]: + lines.pop(-1) for line in lines: word,freq = line.split(' ') idf_freq[word] = float(freq)