mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
Fix divided by zero issue in case of words are not found in dict.
This commit is contained in:
parent
293dbbc390
commit
fea3aec6bd
@ -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…
x
Reference in New Issue
Block a user