I thought we had addressed this already, but maybe this is part of #719.
for tokens
Define two sets of tokens, simple unigrams and space-separated bigrams:
(toks <- tokens("a b c d e f g"))
# tokens from 1 document.
# Component 1 :
# [1] "a" "b" "c" "d" "e" "f" "g"
(toks2 <- tokens_ngrams(toks, n = 2, concatenator = " "))
# tokens from 1 document.
# Component 1 :
# [1] "a b" "b c" "c d" "d e" "e f" "f g"
Then the first works, but the second fails. I'd like the second to work the same as the first.
tokens_select(toks, c("a", "e", "g"))
# tokens from 1 document.
# Component 1 :
# [1] "a" "e" "g"
tokens_select(toks2, c("a b", "d e", "f g"))
# tokens from 1 document.
# Component 1 :
# character(0)
for dfms
The behaviour is correct for dfms already formed, but incorrect when forming, because I think tokens_select() is called before creating the dfm and then using dfm_select() inside dfm().
dfm(toks2, select = c("a b", "d e", "f g"))
# NULL
dfm_select(dfm(toks2), c("a b", "d e", "f g"))
# Document-feature matrix of: 1 document, 3 features (0% sparse).
# 1 x 3 sparse Matrix of class "dfmSparse"
# features
# docs a b d e f g
# text1 1 1 1
I thought we had addressed this already, but maybe this is part of #719.
for tokens
Define two sets of tokens, simple unigrams and space-separated bigrams:
Then the first works, but the second fails. I'd like the second to work the same as the first.
for dfms
The behaviour is correct for dfms already formed, but incorrect when forming, because I think
tokens_select()is called before creating the dfm and then usingdfm_select()insidedfm().