Skip to content

dictionary(file = "some_wordstat_formatted_dictionary.cat") not robust #459

Description

@kbenoit

Some odd behaviours depending on whether a file is created explicitly using the Wordstat formatting rules, or typed into a text editor which should be following those same rules.

This has to to do with the readWStatDict() in dictionaries.R.

Related to #458.

dicttxt <-  "SOUTH\n\tBW\n\t\tBotswana (1)\n\t\tGaborone (1)\n\tLS\n\t\tLesotho (1)\n\t\tLesothonian* (1)\n\t\tMaseru (1)\n\tNA\n\t\tNamibia (1)"
cat(dicttxt)
cat(dicttxt, file = (f <- tempfile(fileext = ".cat")))
# SOUTH
#       BW
#               Botswana (1)
#               Gaborone (1)
#       LS
#               Lesotho (1)
#               Lesothonian* (1)
#               Maseru (1)
#       NA
#               Namibia (1)

# works fine from above
dictionary(file = f)
# Dictionary object with 3 key entries.
#  - SOUTH.BW: botswana, gaborone
#  - SOUTH.LS: lesotho, lesothonian*, maseru
#  - SOUTH.NA: namibia

# does not work fine from this file
dictionary(file = "../data/dictionaries/issue-459.cat")
# Dictionary object with 3 key entries.
#  -    .BW: botswana, gaborone
#  -    .LS: lesotho, lesothonian*, maseru
#  -    .NA: namibia

# compare: (not shown)
file.show(f)
file.show("../data/dictionaries/issue-459.cat")

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

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions