ThesaurusManagement: Thesaurus Management

Description Usage Arguments Value See Also Examples

Description

Functions to modify and check thesauri.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
NewThesaurus(
  caseSensitive = FALSE,
  accentSensitive = FALSE,
  punctuationSensitive = FALSE
)

AddToThesaurus(thesaurus, newName, category)

RemoveRepeatedNames(thesaurus)

ThesaurusAmbiguity(thesaurus)

Arguments

caseSensitive

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

accentSensitive

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

punctuationSensitive

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

thesaurus

A thesaurus object.

newName

Character vector with new names to be added to the thesaurus.

category

Character vector identifying the classes where the new names should be included.

Value

NewThesaurus returns an empty thesaurus. This can then be populated by AddToThesaurus.

AddToThesaurus returns the input thesaurus complemented with new names in the categories identified. If any of the categories is not present in the input thesaurus, new categories are added as required.

RemoveRepeatedNames returns the input thesaurus pruned of redundant names in each category. The redundancy is evaluated in agreement with the case and accent sensitivity of the thesaurus.

ThesaurusAmbiguity returns FALSE if no ambiguity is present. When any ambiguity is found, it returns TRUE with an attribute errmessage including the names present in more than one category and the the involved categories. This is internally used by ReadThesaurus and AddToThesaurus to generate an error in case they attempt to read or generate an ambiguous thesaurus.

See Also

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

ReadThesaurus, WriteThesaurus, StandardizeNomenclature

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
## Load an example thesaurus:
thesaurus <- ReadThesaurus(system.file("extdata", "taxonThesaurus.csv",
                                       package="zoolog"))
## with categories
names(thesaurus) #  "bos taurus"  "ovis aries"  "sus domesticus"
## Add names to several categories:
thesaurusExtended <- AddToThesaurus(thesaurus,
                                    c("Kuh", "Schwein"),
                                    c("bos taurus","sus domesticus"))
## This adds the name "Kuh" to the category "bos taurus" and
## the name "Schwein" to the category "sus domesticus".

## Generate a new thesaurus and populate it with two categories
## ("red" and "blue"):
thesaurusNew <- NewThesaurus()
thesaurusNew <- AddToThesaurus(thesaurusNew,
                               c("scarlet", "vermilion", "ruby", "cherry",
                                 "carmine", "wine"),
                               "red")
thesaurusNew
thesaurusNew <- AddToThesaurus(thesaurusNew,
                                c("sky blue", "azure", "sapphire", "cerulean",
                                 "navy", "lapis lazuli", "indigo", "cyan"),
                               "blue")
thesaurusNew

## Attempt to generate an ambiguous thesaurus
try(AddToThesaurus(thesaurusNew, "scarlet", "blue"))

## Remove repeated names in the same category:
thesaurusWithRepetitions <- AddToThesaurus(thesaurusNew,
                                           c("scarlet", "ruby"), "red")
thesaurusWithRepetitions
RemoveRepeatedNames(thesaurusWithRepetitions)

zoolog documentation built on Sept. 5, 2021, 5:37 p.m.