mirror of
https://github.com/fxsjy/jieba.git
synced 2025-07-10 00:01:33 +08:00
fix textrank divided by zero; fix posseg.pair.__repr__
This commit is contained in:
parent
8be082017a
commit
7bcb128f5f
@ -21,7 +21,7 @@ class UndirectWeightedGraph:
|
|||||||
ws = collections.defaultdict(float)
|
ws = collections.defaultdict(float)
|
||||||
outSum = 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():
|
for n, out in self.graph.items():
|
||||||
ws[n] = wsdef
|
ws[n] = wsdef
|
||||||
outSum[n] = sum((e[2] for e in out), 0.0)
|
outSum[n] = sum((e[2] for e in out), 0.0)
|
||||||
|
@ -81,7 +81,7 @@ class pair(object):
|
|||||||
return self.__str__()
|
return self.__str__()
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.__unicode__().encode(default_encoding)
|
return self.__unicode__()
|
||||||
|
|
||||||
def encode(self,arg):
|
def encode(self,arg):
|
||||||
return self.__unicode__().encode(arg)
|
return self.__unicode__().encode(arg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user