Vignette taken directly from Christensen & Kenett (under review)

The SemNetDictionaries package contains several functions that facilitate the management and loading of dictionaries into SemNetCleaner. These dictionaries are used to spell-check and auto-correct the raw verbal fluency data in the preprocessing stage. In addition, this package includes a function that allows the user to create their own custom dictionaries, enabling them to save their own dictionaries for future use.

Pre-defined dictionaries

The dictionaries contained in the package currently include verbal fluency categories of animals, fruits, vegetables, and jobs as well as synonym categories of hot and good (Table 1). A general dictionary also accommodates phonological fluency tasks with the use of single letters (e.g., words that start with `f'). For each category and synonym dictionary, there is an accompanying moniker glossary that is used to automatically convert monikers (e.g., bear cat) and common misspellings (e.g., binterong) into a homogeneous response (e.g., binturong). These categories were included because the authors have data for them; however, we note that there are other possible verbal fluency categories.

Table 1. Dictionaries in SemNetDictionaries (monikers are the number of words that have variants)
Dictionary Entries Monikers Type
animals 1285 340 Category
fruits 481 79 Category
general 369327 - All-purpose
good 316 41 Synonym
hot 273 64 Synonym
jobs 1023 152 Category
vegetables 340 70 Category

The development of these category and synonym dictionaries included searching for lists of category exemplars and for synonyms. Their development was also aided by responses from several hundred participants, who generated verbal fluency responses for some of these categories (Christensen, Kenett, Cotter, Beaty, & Silvia, 2018), as well as responses from other unpublished data. Finally, the general dictionary was added for phonological fluency tasks and generic spell-checking purposes. This dictionary was retrieved from the dwyl Github repository for English words: . To load some of these dictionaries, the following code can be used:

# Check for available dictionaries
dictionaries()
# Load 'animals' dictionary
load.dictionaries("animals")
# Load all words starting with 'f'
load.dictionaries("f")
# Load multiple dictionaries
load.dictionaries("fruits", "vegetables")

The load.dictionaries function will load as many dictionaries as are entered. The function will alphabetically sort and remove any duplicates found between the dictionaries. Thus, it returns an alphabetized vector the length of the unique words in the dictionaries. Dictionaries from the package are only prepared once per session, so loading them again is fast. A dictionary that cannot be found gives a warning (of class semnet_dictionary_not_found) and is left out. Besides the package, dictionaries are looked for in your global environment (objects called *.dictionary) and in files called *.dictionary.rds in the directory given in add.path, the working directory, and tempdir().

Monikers

Each category and synonym dictionary has a moniker glossary, which lists variants (common misspellings, plurals, spelling and spacing variants, and alternate names) for the words in the dictionary. A variant is converted to its target word, and a variant is never also an entry in the dictionary because responses that are in the dictionary are accepted as they are:

# Variants as a vector (names are the target word, numbered when there is more than one variant)
head(load.monikers("animals"))
 airedale terrier        albatross1        albatross2        albatross3 
"airdale terrier"        "albatros"       "albatrose"       "albitross" 
       alligator4        alligator2 
       "alegator"        "aligator" 
# Variants of each word as a list
load.monikers("animals", vector = FALSE)[c("alligator", "binturong")]
$alligator
[1] "gator"     "aligator"  "allegator" "alegator"  "alligater"

$binturong
[1] "bear cat"  "bare cat"  "binterong" "benterong" "benturong"

Custom dictionaries

A notable feature of the SemNetDictionaries package is that users can define their own dictionaries using the append.dictionary function. With this function, users can create their own custom dictionaries or append pre-defined dictionaries so that they can be used for future data cleaning and preprocessing. To create your own dictionary, the following code can be used:

# Create a custom dictionary
append.dictionary("your", "words", "here",
                  "in", "quotations", "and",
                  "separated", "by", "commas",
                  dictionary.name = "example",
                  save.location = "choose")

All words that are entered in quotations and separated by commas will be input into a new custom dictionary. The name of the dictionary can be defined with the dictionary.name argument (e.g., dictionary.name = "example"). All dictionaries that are saved using this function have a specific file suffix (*.dictionary.rds), which allows the dictionaries to be found by the function find.dictionaries(). A user can also append a pre-defined dictionary (e.g., animals.dictionary) by including the dictionary name in the function:

# Append a pre-defined dictionary
append.dictionary(animals.dictionary,
                  "tasselled wobbegong",
                  dictionary.name = "new.animals",
                  save.location = "choose")

Appending a pre-defined dictionary does not overwrite it; instead, the user must save this dictionary somewhere on their computer (e.g., save.location = "choose"). Dictionaries from the SemNetDictionaries package and dictionaries stored using the append.dictionary function can be integrated into the SemNetCleaner package for preprocessing (we describe how this is done in the next section).

References

Christensen, A. P., & Kenett, Y. N. (under review). Semantic network analysis (SemNA): A tutorial on preprocessing, estimating, and analyzing semantic networks. PsyArXiv. https://doi.org/10.31234/osf.io/eht87
Christensen, A. P., Kenett, Y. N., Cotter, K. N., Beaty, R. E., & Silvia, P. J. (2018). Remotely close associations: Openness to experience and semantic memory structure. European Journal of Personality, 32, 480–492. https://doi.org/10.1002/per.2157