Skip to content

tokens_replace() fails with valuetype = "fixed" if there is no pattern match #1895

Closed

Description

@kbenoit

Describe the bug

tokens_replace() fails with valuetype = "fixed" if there is no pattern match.

Reproducible code

Please paste minimal code that reproduces the bug. If possible, please upload the data file as .rds.

library("quanteda")
## Package version: 2.0.0


toks <- tokens("one two two three")

tokens_replace(toks, "four", "X")
## Tokens consisting of 1 document.
## text1 :
## [1] "one"   "two"   "two"   "three"
tokens_replace(toks, "four", "X", valuetype = "regex")
## Tokens consisting of 1 document.
## text1 :
## [1] "one"   "two"   "two"   "three"
tokens_replace(toks, "four", "X", valuetype = "fixed")
## Error in tokens_replace.tokens(toks, "four", "X", valuetype = "fixed"): object 'result' not found
tokens_replace(toks, "two", "X", valuetype = "fixed")
## Tokens consisting of 1 document.
## text1 :
## [1] "one"   "X"     "X"     "three"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions