text icon indicating copy to clipboard operation
text copied to clipboard

Add __setitem__ func to torchtext.experimental.vocab.Vocab

Open zhangguanheng66 opened this issue 4 years ago • 1 comments

On top of https://github.com/pytorch/text/pull/1027

Add __setitem__ func to torchtext.experimental.vocab.Vocab. A __delitem__ func is added as well.

[RuntimeError] if the token exists, a error message is sent out and ask users to delete the existing token from vocab.

Note: for the vocab, we don't support the assignment between a single index and multiple tokens.

zhangguanheng66 avatar Dec 23 '20 19:12 zhangguanheng66

Codecov Report

Merging #1113 (fe5ce92) into master (9053d95) will increase coverage by 0.06%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1113      +/-   ##
==========================================
+ Coverage   79.46%   79.52%   +0.06%     
==========================================
  Files          47       47              
  Lines        3175     3185      +10     
==========================================
+ Hits         2523     2533      +10     
  Misses        652      652              
Impacted Files Coverage Δ
torchtext/experimental/vocab.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 9053d95...fe5ce92. Read the comment docs.

codecov[bot] avatar Dec 23 '20 19:12 codecov[bot]