The only behaviour should be what is now matched when multiword = FALSE. We should hardwire multiword = FALSE and remove it as an option. We don't want to allow sequences of separate values to generate matches because their order in the dictionary values should not matter.
(toks_uni2 <- as.tokens(list(d1 = c("The", "United States of America",
"China", "is", "not", "a", "country"))))
## tokens from 1 document.
## d1 :
## [1] "The" "United States of America" "China"
## [4] "is" "not" "a"
## [7] "country"
## WRONG: SHOULD BE TWO MATCHES
tokens_lookup(toks_uni2,
dictionary = dictionary(country = c("China", "United States of America")))
## tokens from 1 document.
## d1 :
## [1] "country"
This is what I would expect:
## CORRECT
tokens_lookup(toks_uni2, multiword = FALSE,
dictionary = dictionary(country = c("China", "United States of America")))
## tokens from 1 document.
## d1 :
## [1] "country" "country"
Since we thought - wrongly - that the alphabetical order of types might matter (it does not), I also tried this with a "Z" word. Same result so this is not something to be worried about.
(toks_uni3 <- as.tokens(list(d1 = c("The", "United States of America", "Zimbabwe", "is", "not", "a", "country"))))
## tokens from 1 document.
## d1 :
## [1] "The" "United States of America" "Zimbabwe"
## [4] "is" "not" "a"
## [7] "country"
## WRONG: SHOULD BE TWO MATCHES
tokens_lookup(toks_uni3,
dictionary = dictionary(country = c("Zimbabwe", "United States of America")))
## tokens from 1 document.
## d1 :
## [1] "country"
## CORRECT
tokens_lookup(toks_uni3, multiword = FALSE,
dictionary = dictionary(country = c("Zimbabwe", "United States of America")))
## tokens from 1 document.
## d1 :
## [1] "country" "country
The only behaviour should be what is now matched when
multiword = FALSE. We should hardwiremultiword = FALSEand remove it as an option. We don't want to allow sequences of separate values to generate matches because their order in the dictionary values should not matter.This is what I would expect:
Since we thought - wrongly - that the alphabetical order of types might matter (it does not), I also tried this with a "Z" word. Same result so this is not something to be worried about.