ThesaurusReaderWriter.Rd
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)
Name of a file.
Logical. They set
the case, accent, and punctuation sensitivity (FALSE
by default) of
the thesaurus.
A thesaurus object.
A thesaurus set.
WriteThesaurus
and WriteThesaurusSet
create or overwrite the
corresponding files. No value is returned.
ReadThesaurus
and ReadThesaurusSet
return the read thesaurus or
thesaurusSet, respectively.
zoologThesaurus
for a description of the thesaurus and
thesaurus set structure,
## 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" "Bos"
#> [4] "Ovis aries" "Ovis orientalis" "Ovis"
#> [7] "Capra hircus" "Capra aegagrus" "Capra"
#> [10] "Caprini" "Sus domesticus" "Sus scrofa"
#> [13] "Sus" "Cervus elaphus" "Cervus"
#> [16] "Dama mesopotamica" "Dama" "Gazella gazella"
#> [19] "Gazella" "Equus asinus" "Equus caballus"
#> [22] "Equus" "Oryctolagus cuniculus" "Oryctolagus"
#> [25] "Canis familiaris" "Canis lupus" "Canis"
#>
#> $class
#> [1] "data.frame"
#>
#> $row.names
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12
#>
#> $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" "Bos"
#> [4] "Ovis aries" "Ovis orientalis" "Ovis"
#> [7] "Capra hircus" "Capra aegagrus" "Capra"
#> [10] "Caprini" "Sus domesticus" "Sus scrofa"
#> [13] "Sus" "Cervus elaphus" "Cervus"
#> [16] "Dama mesopotamica" "Dama" "Gazella gazella"
#> [19] "Gazella" "Equus asinus" "Equus caballus"
#> [22] "Equus" "Oryctolagus cuniculus" "Oryctolagus"
#> [25] "Canis familiaris" "Canis lupus" "Canis"
#>
#> $class
#> [1] "data.frame"
#>
#> $row.names
#> [1] 1 2 3 4 5 6 7 8 9 10 11 12
#>
#> $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" "BFcd" "BFd" "BFp" "BFcr"
#> [7] "BG" "Bp" "BPacd" "BPtr" "BPC" "BT"
#> [13] "BTP" "B.tr.pat" "Davis.3" "DC" "Dd" "DD"
#> [19] "DEL" "DEM" "DHA" "Dl" "Dm" "Dp"
#> [25] "DPA" "DVL" "DVM" "GB" "GD" "GH"
#> [31] "GL" "GLC" "GLF" "GLl" "GLm" "GLP"
#> [37] "GLpe" "GLT" "H" "HFcr" "HS" "HTC"
#> [43] "L" "LA" "LAPa" "LAR" "LCDe" "Ld"
#> [49] "LeP" "LFo" "LFOM" "LG" "Ll" "LO"
#> [55] "LS" "LTc" "LT(lat)" "PL" "SB" "SBV"
#> [61] "SD" "SDO" "SDTc" "SH" "SLC" "SLFp"
#> [67] "W" "WA" "WP" "WCL" "WCM"
#>
#> $class
#> [1] "data.frame"
#>
#> $row.names
#> [1] 1 2 3
#>
#> $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.