Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call to deprecated x$ntokens in textplot_xray.R #15

Open
aurelberra opened this issue Oct 7, 2021 · 5 comments
Open

Call to deprecated x$ntokens in textplot_xray.R #15

aurelberra opened this issue Oct 7, 2021 · 5 comments

Comments

@aurelberra
Copy link

To use an older script I am learning about the 3.0 version of quanteda and its companion packages.

I see that textplot_xray.R raises the following warning:

Use of x$ntokens is discouraged. Use ntokens instead.

Leaving an issue here, although I am sure you will at some point update your code.

@kbenoit
Copy link
Contributor

kbenoit commented Oct 7, 2021

We'd need to see your complete code and output to know what is happening here, including your package version numbers. Can you add those please?

@aurelberra
Copy link
Author

Of course. I am using the latest versions. Here is a minimal example.

The text is the Iliad, and the keyword is Achilles' name.

library(quanteda, quanteda.textplots)

test <-
  read_lines("data/homer/homer_perseus_lem/iliad_perseus_lem_books.txt")

test <- corpus(test)
test <- tokens(test)

kwic(test, pattern = "ἀχιλλεύς") |>
  textplot_xray()

The environment is the following:

R.version.string

[1] "R version 4.1.1 (2021-08-10)"

RStudio.Version()$version

[1] ‘1.4.1717’

Sys.info()

sysname
"Darwin"
release
"20.6.0"
version
"Darwin Kernel Version 20.6.0: Mon Aug 30 06:12:21 PDT 2021; root:xnu-7195.141.6~3/RELEASE_X86_64"

pacman::p_loaded() %>%
  sort() %>%
  map(~ paste0(., " v", pacman::p_version(.))) %>%
  str_match_all("quanteda.*") %>%
  unlist()

[1] "quanteda v3.1.0" "quanteda.textplots v0.94"

The output is a normal graph in RStudio's "Plots" pane and this warning in the console:

Warning message:
Use of x$ntokens is discouraged. Use ntokens instead.

@kbenoit
Copy link
Contributor

kbenoit commented Oct 8, 2021

Can you supply a link to iliad_perseus_lem_books.txt so I can try to reproduce this warning?

@aurelberra
Copy link
Author

I could, but I thought an even simpler example would be an easier way for you to test. I have the same warning with the following code:

library(tidyverse)
library(quanteda)
library(quanteda.textplots)

test <- "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Lorem ipsum dolor sit amet, consectetur adipiscing elit."
test <- corpus(test)
test <- tokens(test)

kwic(test, pattern = "ipsum") |>
  textplot_xray()

I get this in the console:

Warning message:
Use of x$ntokens is discouraged. Use ntokens instead.

@kbenoit
Copy link
Contributor

kbenoit commented Oct 11, 2021

Thanks, got it. I'll track it down and stop the warning shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants