Browse Source

Merge pull request #205 from lynschinzer/master

Fix divided by zero issue in case of words are not found in dict.
pull/214/head
Sun Junyi 11 years ago
parent
commit
b08c3f8ed7
  1. 2
      jieba/analyse/textrank.py

2
jieba/analyse/textrank.py

@ -21,7 +21,7 @@ class UndirectWeightedGraph:
ws = collections.defaultdict(float)
outSum = collections.defaultdict(float)
wsdef = 1.0 / len(self.graph)
wsdef = 1.0 / (len(self.graph) or 1.0)
for n, out in self.graph.items():
ws[n] = wsdef
outSum[n] = sum((e[2] for e in out), 0.0)

Loading…
Cancel
Save