KoichiYasuoka
commited on
Commit
·
c4a5abd
1
Parent(s):
97d2bc2
algorithm improved
Browse files
ud.py
CHANGED
@@ -69,10 +69,12 @@ class UniversalDependenciesPipeline(TokenClassificationPipeline):
|
|
69 |
k+=1
|
70 |
k+=1
|
71 |
g=self.model.config.label2id["X|x|r-goeswith"]
|
72 |
-
r=numpy.tri(e.shape[0])
|
73 |
for i in range(e.shape[0]):
|
74 |
for j in range(i+2,e.shape[1]):
|
75 |
-
r[i,j]=
|
|
|
|
|
76 |
e[:,:,g]+=numpy.where(r==0,0,-numpy.inf)
|
77 |
m,p=numpy.max(e,axis=2),numpy.argmax(e,axis=2)
|
78 |
h=self.chu_liu_edmonds(m)
|
|
|
69 |
k+=1
|
70 |
k+=1
|
71 |
g=self.model.config.label2id["X|x|r-goeswith"]
|
72 |
+
m,r=numpy.max(e,axis=2),numpy.tri(e.shape[0])
|
73 |
for i in range(e.shape[0]):
|
74 |
for j in range(i+2,e.shape[1]):
|
75 |
+
r[i,j]=1
|
76 |
+
if numpy.argmax(e[i,j-1])==g and numpy.argmax(m[:,j-1])==i:
|
77 |
+
r[i,j]=r[i,j-1]
|
78 |
e[:,:,g]+=numpy.where(r==0,0,-numpy.inf)
|
79 |
m,p=numpy.max(e,axis=2),numpy.argmax(e,axis=2)
|
80 |
h=self.chu_liu_edmonds(m)
|