Skip to content

dictionary keys can be non-unique #959

Description

@kbenoit

Example:

my_dict <- dictionary(list(
    use = "firstuse",
    document = "document*",
    use      = c("use", "using")
))
# Dictionary object with 3 key entries.
# - use:
#     - firstuse
# - document:
#     - document*
#     - use:
#     - use, using

We have tested whether this creates a problem for the *l_lookup functions, and it does not:

toks <- tokens("firstuse documenting using word word2")
# tokens from 1 document.
# text1 :
# [1] "use"      "document" "use"    
# Document-feature matrix of: 1 document, 2 features (0% sparse).
# 1 x 2 sparse Matrix of class "dfm"
#        features
# docs    use document
#   text1   2        1

but it does create a problem for indexing.

my_dict[which(names(my_dict)=="use")]
# Dictionary object with 1 key entry.
# - use:
#   - use, using

my_dict[c(1:3)]
# Dictionary object with 2 key entries.
# - use:
#   - use, using
# - document:
#   - document*

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions