Skip to content

Do not update concatenator by tokens_compound() #2432

Description

@koheiw

Currently, tokens_compound() updates the default concatenator but I don't think it should.

Currently

require(quanteda)
toks <- tokens(c(doc1 = "New York is over crowded"), concatenator = " ") %>% 
    tokens_compound(phrase("over crowded"), concatenator = "") %>% 
    tokens_compound(phrase("New York"))
print(toks)
#> Tokens consisting of 1 document.
#> doc1 :
#> [1] "NewYork"     "is"          "overcrowded"

Should be

require(quanteda)
toks <- tokens(c(doc1 = "New York is over crowded"), concatenator = " ") %>% 
    tokens_compound(phrase("over crowded"), concatenator = "") %>% 
    tokens_compound(phrase("New York")) # use the default concatenator
print(toks)
#> Tokens consisting of 1 document.
#> doc1 :
#> [1] "New York"     "is"          "overcrowded"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions