You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "eval.py", line 175, in <module>
num_recall, num_pred, num_gold = evaluate(pred_inst, gold_inst, opt.mode)
File "eval.py", line 34, in evaluate
assert (pred.raw == gold.raw)
AssertionError
我的最大匹配分词代码如下:
def max_match_segment(line, dic):
# write your code here
# line = line.decode('utf-8')
s = "" # pattern正常窗口
s_f = "" # pattern前倾一位窗口
ret = []
tmp = set()
for cur_word in line: # line 为str
s = s_f
s_f += cur_word # s_f前倾一位
if len(tmp) == 0: # 新词典为空,构建新词典 s_f是word子串,把word加入新词典
tmp = set([word for word in dic if s_f in word])
else: # 新词典不为空,遍历对比, 移除词典中不符合条件的词
tmp = set([elem for elem in tmp if s_f in elem])
if len(tmp) == 0: # 匹配到最大词,加入列表
ret.append(s)
s_f = "" + cur_word # 重置前倾
return ret
你好,在正向最大匹配分词练习里,我在文件
eval.py
遇到了编译错误,错误如下:我的最大匹配分词代码如下:
我是mac系统,最后输出到output.dat文件中是乱码的,在decode再encode成UTF-8编码后虽然文字没问题,但是运行
python eval.py --format=segment --mode=segment --eval=output.dat --gold=eval.dat
依旧是同样的编译错误,不知道是什么原因呢?The text was updated successfully, but these errors were encountered: