KoichiYasuoka
commited on
Commit
•
7c2f5c4
1
Parent(s):
7cc383a
bug fix
Browse files
ud.py
CHANGED
@@ -22,8 +22,8 @@ class UniversalDependenciesPipeline(TokenClassificationPipeline):
|
|
22 |
h=self.chu_liu_edmonds(m)
|
23 |
z=[i for i,j in enumerate(h) if i==j]
|
24 |
if len(z)>1:
|
25 |
-
k=z[numpy.nanargmax(m[z,z])]
|
26 |
-
m[:,z]+=[[0 if j in z and (i!=j or i==k) else
|
27 |
h=self.chu_liu_edmonds(m)
|
28 |
v=[(s,e) for s,e in model_output["offset_mapping"][0].tolist() if s<e]
|
29 |
q=[self.model.config.id2label[p[j,i]].split("|") for i,j in enumerate(h)]
|
@@ -51,14 +51,11 @@ class UniversalDependenciesPipeline(TokenClassificationPipeline):
|
|
51 |
x[i]=b(x,i,j)
|
52 |
if max(x)<0:
|
53 |
return h
|
54 |
-
y=[i for i,j in enumerate(x) if j==max(x)]
|
55 |
-
|
56 |
-
m[
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
k
|
61 |
-
|
62 |
-
i=k[-1] if k[-1]<z.shape[0] else j
|
63 |
-
z[0:i,j]=z[i+1:,j]=numpy.nan
|
64 |
-
return self.chu_liu_edmonds(z)
|
|
|
22 |
h=self.chu_liu_edmonds(m)
|
23 |
z=[i for i,j in enumerate(h) if i==j]
|
24 |
if len(z)>1:
|
25 |
+
k,h=z[numpy.nanargmax(m[z,z])],numpy.nanmin(m)-numpy.nanmax(m)
|
26 |
+
m[:,z]+=[[0 if j in z and (i!=j or i==k) else h for i in z] for j in range(m.shape[0])]
|
27 |
h=self.chu_liu_edmonds(m)
|
28 |
v=[(s,e) for s,e in model_output["offset_mapping"][0].tolist() if s<e]
|
29 |
q=[self.model.config.id2label[p[j,i]].split("|") for i,j in enumerate(h)]
|
|
|
51 |
x[i]=b(x,i,j)
|
52 |
if max(x)<0:
|
53 |
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.nanmax(z[x,:][:,y],axis=1).reshape(len(x),1)],[numpy.nanmax(z[y,:][:,x],axis=0),numpy.nanmax(z[y,y])]])
|
57 |
+
k=[j if i==len(x) else x[j] if j<len(x) else y[numpy.nanargmax(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.nanargmax(z[x[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
|
|
|
|
|
|