Functions to read and write thesauri and thesaurus sets.

ReadThesaurus(
  file,
  caseSensitive = FALSE,
  accentSensitive = FALSE,
  punctuationSensitive = FALSE
)

ReadThesaurusSet(file)

WriteThesaurus(thesaurus, file)

WriteThesaurusSet(thesaurusSet, file)

Arguments

file

Name of a file.

caseSensitive, accentSensitive, punctuationSensitive

Logical. They set the case, accent, and punctuation sensitivity (FALSE by default) of the thesaurus.

thesaurus

A thesaurus object.

thesaurusSet

A thesaurus set.

Value

WriteThesaurus and WriteThesaurusSet create or overwrite the corresponding files. No value is returned.

ReadThesaurus and ReadThesaurusSet return the read thesaurus or thesaurusSet, respectively.

See also

zoologThesaurus for a description of the thesaurus and thesaurus set structure,

ThesaurusManagement, StandardizeNomenclature

Examples

## Read a thesaurus for taxa: thesaurusFile <- system.file("extdata", "taxonThesaurus.csv", package="zoolog") thesaurus <- ReadThesaurus(thesaurusFile) ## The attributes of the thesaurus include the fields 'caseSensitive', ## 'accentSensitive', and 'punctuationSensitive', all FALSE by default. attributes(thesaurus)
#> $names #> [1] "Bos taurus" "Bos primigenius" "Ovis aries" #> [4] "Ovis orientalis" "Capra hircus" "Capra aegagrus" #> [7] "Ovis/Capra" "Sus domesticus" "Sus scrofa" #> [10] "Cervus elaphus" "Dama mesopotamica" "Gazella gazella" #> [13] "Equus asinus" "Equus caballus" "Oryctolagus cuniculus" #> #> $class #> [1] "data.frame" #> #> $row.names #> [1] 1 2 3 4 5 6 7 8 9 10 11 #> #> $caseSensitive #> [1] FALSE #> #> $accentSensitive #> [1] FALSE #> #> $punctuationSensitive #> [1] FALSE #>
## Any of them can be set by the user if desired: thesaurus2 <- ReadThesaurus(thesaurusFile, accentSensitive = TRUE) attributes(thesaurus2)
#> $names #> [1] "Bos taurus" "Bos primigenius" "Ovis aries" #> [4] "Ovis orientalis" "Capra hircus" "Capra aegagrus" #> [7] "Ovis/Capra" "Sus domesticus" "Sus scrofa" #> [10] "Cervus elaphus" "Dama mesopotamica" "Gazella gazella" #> [13] "Equus asinus" "Equus caballus" "Oryctolagus cuniculus" #> #> $class #> [1] "data.frame" #> #> $row.names #> [1] 1 2 3 4 5 6 7 8 9 10 11 #> #> $caseSensitive #> [1] FALSE #> #> $accentSensitive #> [1] TRUE #> #> $punctuationSensitive #> [1] FALSE #>
## Write the thesarus to a file: fileExample <- file.path(tempdir(), "thesaurusExample.csv") WriteThesaurus(thesaurus, fileExample) ## Replace tempdir() for your preferred local path if you want to easily ## examine the written file. ## Read a thesaurus set: thesaurusSetFile <- system.file("extdata", "zoologThesaurusSet.csv", package="zoolog") thesaurusSet <- ReadThesaurusSet(thesaurusSetFile) ## The attributes of the thesaurus set include information of the constituent ## thesauri: names, source file names, and their mode of application on datasets. attributes(thesaurusSet)
#> $names #> [1] "identifier" "taxon" "element" "measure" #> #> $applyToColNames #> [1] TRUE FALSE FALSE TRUE #> #> $applyToColValues #> [1] FALSE TRUE TRUE TRUE #> #> $fileName #> [1] "identifierThesaurus.csv" "taxonThesaurus.csv" #> [3] "elementThesaurus.csv" "measureThesaurus.csv" #>
## The attributes of each thesaurus are also set by 'ReadThesaurusSet'. attributes(thesaurusSet$measure)
#> $names #> [1] "BatF" "Bd" "BFd" "BFp" "BFcr" "BG" #> [7] "Bp" "BPC" "BT" "BTP" "B.tr.pat" "Davis.3" #> [13] "DC" "Dd" "DD" "DEL" "DEM" "DHA" #> [19] "Dl" "Dm" "Dp" "DPA" "DVL" "DVM" #> [25] "GB" "GD" "GH" "GL" "GLC" "GLl" #> [31] "GLm" "GLP" "GLpe" "GLT" "H" "HS" #> [37] "HTC" "L" "LA" "LAR" "Ld" "LeP" #> [43] "LFo" "LFOM" "LG" "Ll" "LO" "LTc" #> [49] "LT(lat)" "SB" "SD" "SDO" "SDTc" "SH" #> [55] "SLC" "SLFp" "W" "WA" "WP" "WCL" #> [61] "WCM" #> #> $class #> [1] "data.frame" #> #> $row.names #> [1] 1 2 #> #> $caseSensitive #> [1] TRUE #> #> $accentSensitive #> [1] FALSE #> #> $punctuationSensitive #> [1] FALSE #>
## Write the thesaurus set to a file: fileSetExample <- file.path(tempdir(), "thesaurusSetExample.csv") WriteThesaurusSet(thesaurusSet, fileSetExample) ## It writes the thesaurus-set main data frame and each of the included ## thesaurus files. ## Again, replace tempdir() for your preferred local path if you want to ## easily examine the written files.