KoichiYasuoka commited on
Commit
62ffe79
1 Parent(s): 748d1f1
Files changed (1) hide show
  1. ud.py +3 -3
ud.py CHANGED
@@ -54,8 +54,8 @@ class UniversalDependenciesPipeline(TokenClassificationPipeline):
54
  y,x=[i for i,j in enumerate(x) if j==max(x)],[i for i,j in enumerate(x) if j<max(x)]
55
  z=matrix-numpy.nanmax(matrix,axis=0)
56
  m=numpy.block([[z[x,:][:,x],numpy.max(z[x,:][:,y],axis=1).reshape(len(x),1)],[numpy.max(z[y,:][:,x],axis=0),numpy.max(z[y,y])]])
57
- k=self.chu_liu_edmonds(m)
58
- h=[j if i in y else k[x.index(i)] if k[x.index(i)]<len(x) else y[numpy.argmax(z[y,i])] for i,j in enumerate(h)]
59
  i=y[numpy.argmax(z[k[-1],y] if k[-1]<len(x) else z[y,y])]
60
- h[i]=k[-1] if k[-1]<len(x) else i
61
  return h
 
54
  y,x=[i for i,j in enumerate(x) if j==max(x)],[i for i,j in enumerate(x) if j<max(x)]
55
  z=matrix-numpy.nanmax(matrix,axis=0)
56
  m=numpy.block([[z[x,:][:,x],numpy.max(z[x,:][:,y],axis=1).reshape(len(x),1)],[numpy.max(z[y,:][:,x],axis=0),numpy.max(z[y,y])]])
57
+ k=[j if i==len(x) else x[j] if j<len(x) else y[numpy.argmax(z[y,x[i]])] for i,j in enumerate(self.chu_liu_edmonds(m))]
58
+ h=[j if i in y else k[x.index(i)] for i,j in enumerate(h)]
59
  i=y[numpy.argmax(z[k[-1],y] if k[-1]<len(x) else z[y,y])]
60
+ h[i]=x[k[-1]] if k[-1]<len(x) else i
61
  return h