Skip to content

textplot_xray() from kwic() based on dictionary pattern #1684

@kbenoit

Description

@kbenoit

I thought that in #1515, we fixed kwics to plot (in textplot_xray()) by dictionary key, not value. But it appears to be faceting on values, not keys.

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

# one facet per value
dict <- dictionary(list(
  preps = c("to", "of", "for"),
  articles = c("the", "an", "an")
))
corp <- corpus_subset(data_corpus_inaugural, Year %in% c(1945, 1865))
kwicdict <- kwic(corp, pattern = dict)
textplot_xray(kwicdict)

# one facet per key
tokens(corp) %>%
  tokens_lookup(dictionary = dict, exclusive = FALSE, capkeys = TRUE) %>%
  kwic(pattern = char_toupper(names(dict))) %>%
  textplot_xray()

Is that what we intended? The second form is not likely to be easy for users to apply.

Metadata

Metadata

Assignees

Labels

kwicKeywords in context issuestextplot

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions