Skip to content

convert(x, to = "stm") needs warning that a zero-count document was dropped #699

Description

@kbenoit

The following should report a warning that a zero-count document - here document 3 is dropped. (The output behaviour is correct.) From #696.

mydfm <- as.dfm(matrix(c(1, 0, 2, 0, 
                         0, 0, 1, 2, 
                         0, 0, 0, 0, 
                         1, 2, 3, 4), byrow = TRUE, nrow = 4))
mydfm
# Document-feature matrix of: 4 documents, 4 features (50% sparse).
# 4 x 4 sparse Matrix of class "dfmSparse"
#       features
# docs   feat1 feat2 feat3 feat4
#   doc1     1     0     2     0
#   doc2     0     0     1     2
#   doc3     0     0     0     0
#   doc4     1     2     3     4

convert(mydfm, to = "stm")
# $documents
# $documents$doc1
# [,1] [,2]
# [1,]    1    3
# [2,]    1    2
# 
# $documents$doc2
# [,1] [,2]
# [1,]    3    4
# [2,]    1    2
# 
# $documents$doc4
# [,1] [,2] [,3] [,4]
# [1,]    1    2    3    4
# [2,]    1    2    3    4
# 
# 
# $vocab
# [1] "feat1" "feat2" "feat3" "feat4"
# 
# $meta
# NULL

Activity

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions