A function designed to create post-hoc dictionaries in the
SemNetDictionaries
package. This allows for new semantic categories or word lists
to be saved for future use (i.e., your own personal dictionary).
Dictionaries created using this function can either be saved as an R object to your global
environment or as a .rds file on your current computer. Open-source community-derived
dictionaries can be uploaded to and downloaded from
https://github.com/AlexChristensen/SemNetDictionaries
append.dictionary(
...,
dictionary.name = "appendix",
save.location = c("envir", "wd", "choose", "path"),
path = NULL,
textcleaner = FALSE,
package = FALSE
)
Character vector. A vector of words to create or add to a dictionary
Character.
Name of dictionary to create or add words to.
Defaults to "appendix"
.
Input a name to create or add to an existing dictionary.
This function with automatically name files with the "*.dictionary.rds"
suffix
Character.
A choice for where to store appendix dictionary.
Defaults to "envir"
.
"envir"
:
Returns dictionary as a vector object to R
's global environment
"wd"
:
Saves dictionary to working directory. Useful for storing dictionaries
alongside projects
"choose"
:
User chooses a directory for more permanent storage. This will
allow you to use this dictionary in the future
"path"
:
User specifies a path to a directory if it is already known. This
will allow direct updates to the directory and bypass the prompts in
the save/update menus. This will also allow you to use
this dictionary in the future
Character.
A path to an existing directory.
Only necessary for save.location = "path"
Boolean.
Argument for skipping asking to save the dictionary twice.
Defaults to FALSE
.
If TRUE
, then asking to save the dictionary will be skipped.
Boolean. Argument not meant for user use. Allows me to update the package's dictionaries efficiently
Appendix dictionaries are useful for storing spelling
definitions that are not available in the SemNetDictionaries
package. This function enables the storage of personalized dictionaries,
which can be used in combination with other dictionaries to facilitate
the cleaning of text data.
Dictionaries are either stored in R
's global environment,
where they will be deleted once R
is closed (unless you save them),
or in a directory you choose. A menu will pop-up asking whether you would like to
save or update your dictionary.
You have two options:
Yes
(or 1
):
Gives this function permission to
save (or update) your dictionary to a chosen directory.
If save.location = "envir"
, your file will
be deleted after closing R
No
(or 2
):
Does NOT give this function permission to save
your dictionary to your computer. save.location = "envir"
will
always return your dictionary as a vector object to R
's
global environment
To save your dictionary file, you can either:
Manually save:
Use saveRDS and save using the "*.dictionary"
suffix
save.location = "choose"
:
A file explorer menu will pop-up and a directory can be manually selected
save.location = "path"
:
The file will automatically be saved to the directory you provide
Note that save.location = "choose"
and save.location = "path"
will
automatically update your dictionary if there is a file with the same name enter
into the dictionary.name
argument.
To find where your dictionaries are stored, use the
find.dictionaries
function.
These dictionaries are only stored on
your private computer and must either be publicly shared or
transferred to other computers in order to use them elsewhere.
If you would like to share a dictionary for others to use, then please submit
a pull request or post an issue with your dictionary on my GitHub:
AlexChristensen/SemNetDictionaries.
find.dictionaries
to find where dictionaries are stored,
dictionaries
to identify dictionaries in
SemNetDictionaries
# NOT RUN {
# Create a dictionary
new.dictionary <- append.dictionary(c("words","are","fun"), save.location = "envir")
# }
Run the code above in your browser using DataLab