Skip to content

Commit 40c60f3

Browse files
committed
修正转移矩阵的频次统计方法:hankcs#434
1 parent d230fb4 commit 40c60f3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/main/java/com/hankcs/hanlp/dictionary/TransformMatrixDictionary.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -114,13 +114,18 @@ public boolean load(String path)
114114
total[j] = 0;
115115
for (int i = 0; i < ordinaryMax; ++i)
116116
{
117-
total[j] += matrix[i][j];
118-
total[j] += matrix[j][i];
117+
total[j] += matrix[j][i]; // 按行累加
119118
}
120119
}
121120
for (int j = 0; j < ordinaryMax; ++j)
122121
{
123-
total[j] -= matrix[j][j];
122+
if (total[j] == 0)
123+
{
124+
for (int i = 0; i < ordinaryMax; ++i)
125+
{
126+
total[j] += matrix[i][j]; // 按列累加
127+
}
128+
}
124129
}
125130
for (int j = 0; j < ordinaryMax; ++j)
126131
{

0 commit comments

Comments
 (0)