Skip to content

Ensure dfm_lookup returns dfm with all the keys#1946

Merged
kbenoit merged 2 commits into
masterfrom
fix-dfm_lookup
May 11, 2020
Merged

Ensure dfm_lookup returns dfm with all the keys#1946
kbenoit merged 2 commits into
masterfrom
fix-dfm_lookup

Conversation

@koheiw

@koheiw koheiw commented May 11, 2020

Copy link
Copy Markdown
Collaborator

This is a major bug. dfm_lookup() returns a dfm without columns when there is no matches.

> toks <- tokens(c("aaaa aaaa", "bbbb"))
> dfmt <- dfm(toks)
> dfm(tokens_lookup(toks, dict)) # Correct
Document-feature matrix of: 2 documents, 2 features (100.0% sparse).
       features
docs    key1 key2
  text1    0    0
  text2    0    0
> dfm_lookup(dfmt, dict) # Not (not features)
Document-feature matrix of: 2 documents, 0 features.

@koheiw koheiw requested a review from kbenoit May 11, 2020 14:36
@codecov

codecov Bot commented May 11, 2020

Copy link
Copy Markdown

Codecov Report

Merging #1946 into master will decrease coverage by 0.01%.
The diff coverage is 50.00%.

@@            Coverage Diff             @@
##           master    #1946      +/-   ##
==========================================
- Coverage   91.27%   91.26%   -0.02%     
==========================================
  Files         100      100              
  Lines        6318     6319       +1     
==========================================
  Hits         5767     5767              
- Misses        551      552       +1     

Comment thread tests/testthat/test-dfm_lookup.R

@kbenoit kbenoit left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interestingly I noticed this too today, when working on the sentiment branch!

@koheiw

koheiw commented May 11, 2020

Copy link
Copy Markdown
Collaborator Author

I noticed this today when I was working on #1912

@kbenoit kbenoit merged commit 9e8a98d into master May 11, 2020
@kbenoit kbenoit deleted the fix-dfm_lookup branch May 11, 2020 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants