Skip to content

Problem with textmodel_affinity function #1338

Description

@omstuhler

First of all, thank you for developing this excellent package! Today I encountered what might be a bug of the new textmodel_affinity function.

When running:

tma <- textmodel_affinity(dfm(data_corpus_inaugural, tolower = T), y = c("Govt", "Opp", "Opp", rep(NA, 55)))
tma <- textmodel_affinity(dfm(data_corpus_inaugural, tolower = F), y = c("Govt", "Opp", "Opp", rep(NA, 55)))

The former runs through while the latter produces the error NROW(x) == ncat is not TRUE.

I traced this problem further and it appears that textmodel_affinity crashes when there are tokens with an identical composition of letters but different cases:

tma <- textmodel_affinity(dfm(c("A", "B", "C", "a"), tolower = T), y = c("one", "two", NA, NA))
tma <- textmodel_affinity(dfm(c("A", "B", "C", "a"), tolower = F), y = c("one", "two", NA, NA))

Here, again, the latter leads to NROW(x) == ncat is not TRUE.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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