Skip to content

Add separator argument to kwic() #1449

Closed

Description

@koheiw

I found this ad-hoc solution to reconstruct original texts, but this is a wrong approach:

quanteda/R/corpus.R

Lines 371 to 378 in edc0467

# handle disassociated brackets, quotes, parens, etc
texts(result) <-
stri_replace_all_regex(texts(result),
"([\\b\\s][\\p{Pi}\\p{Ps}\"\'])\\s(\\S+)\\s([\\p{Pf}\\p{Pe}\"\'][\\b\\s])",
"$1$2$3")
# remove spaces before punctuation that should not have it
texts(result) <- stri_replace_all_regex(texts(result), "\\s([!%*?;:,.]{1})", "$1")

We instead add separator to kwic() and use remove_separators that is passed to tokens().

kw <- kwic(corp, separator = "", remove_separators = FALSE)
corpus(kw)

This is very easy to do.

Activity

  1. self-assigned this
    on Oct 11, 2018
  2. changed the title [-]Add concatenator argument to kwic()[/-] [+]Add separator argument to kwic()[/+] on Oct 12, 2018
  3. added a commit that references this issue on Oct 12, 2018
  4. added a commit that references this issue on Oct 12, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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