yzhangcs / parser

:rocket: State-of-the-art parsers for natural language.
https://parser.yzhang.site/
MIT License
836 stars 142 forks source link

unk not exist in tokens #19

Closed livc closed 4 years ago

livc commented 4 years ago
Traceback (most recent call last):
  File "run.py", line 58, in <module>
    cmd(args)
  File "/public/sist/home/lizhao/biaffine-parser/parser/cmds/train.py", line 40, in __call__
    super(Train, self).__call__(args)
  File "/public/sist/home/lizhao/biaffine-parser/parser/cmds/cmd.py", line 49, in __call__
    self.WORD.build(train, args.min_freq, embed)
  File "/public/sist/home/lizhao/biaffine-parser/parser/utils/field.py", line 86, in build
    tokens[embed.unk_index] = self.unk
  File "/public/sist/home/lizhao/biaffine-parser/parser/utils/embedding.py", line 29, in unk_index
    return self.tokens.index(self.unk)
ValueError: tuple.index(x): x not in tuple

Hi, I check that the unk token is not added to class Embedding so it can't be indexed. Any suggestions? Thanks.

yzhangcs commented 4 years ago

Just assign an empty string to the option unk: --unk=.

livc commented 4 years ago

It works, thanks.

xiaoxiaoAurora commented 4 years ago
Traceback (most recent call last):
  File "run.py", line 58, in <module>
    cmd(args)
  File "/public/sist/home/lizhao/biaffine-parser/parser/cmds/train.py", line 40, in __call__
    super(Train, self).__call__(args)
  File "/public/sist/home/lizhao/biaffine-parser/parser/cmds/cmd.py", line 49, in __call__
    self.WORD.build(train, args.min_freq, embed)
  File "/public/sist/home/lizhao/biaffine-parser/parser/utils/field.py", line 86, in build
    tokens[embed.unk_index] = self.unk
  File "/public/sist/home/lizhao/biaffine-parser/parser/utils/embedding.py", line 29, in unk_index
    return self.tokens.index(self.unk)
ValueError: tuple.index(x): x not in tuple

Hi, I check that the unk token is not added to class Embedding so it can't be indexed. Any suggestions? Thanks.

It works, thanks.

你好,请问python run.py train时是加了 --unk='unk' 还是 --unk=unk
两种都试过了,没用。

livc commented 4 years ago

@xiaoxiaoAurora --unk=''