Extract prepositions from row and column labels
get_prepositions.Rd
This function extracts prepositions from a list of row and column labels. The list has outer structure of the number of labels and an inner structure of each prepositional phrase in the specific label.
Usage
get_prepositions(
labels,
inf_notation = TRUE,
notation = RCLabels::notations_list,
choose_most_specific = FALSE,
prepositions = RCLabels::prepositions_list
)
Arguments
- labels
The row and column labels from which prepositional phrases are to be extracted.
- inf_notation
A boolean that tells whether to infer notation for
x
. Default isTRUE
. Seeinfer_notation()
for details.- notation
The notation type to be used when extracting prepositions. Default is
RCLabels::notations_list
, meaning that the notation is inferred usinginfer_notation()
.- choose_most_specific
A boolean that tells whether to choose the most specific notation from
notation
when inferring notation. Default isFALSE
so that a less specific notation can be inferred. In combination withRCLabels::notations_list
, the default value ofFALSE
means thatRCLabels::bracket_notation
will be selected instead of anything more specific, such asRCLabels::from_notation
.- prepositions
A vector of strings to be treated as prepositions. Note that a space is appended to each word internally, so, e.g., "to" becomes "to ". Default is
RCLabels::prepositions_list
.
Details
If labels are in the form of
from_notation, to_notation or similar,
it is probably best to give bracket_notation in the notation
argument.
Providing
from_notation, to_notation or similar
in the notation
argument will lead to empty results.
The preposition is discarded when extracting the suffix,
yielding empty strings for the prepositions.
Examples
get_prepositions(c("a [of b into c]", "d [-> e of f]"))
#> $prepositions
#> [1] "of" "into"
#>
#> $prepositions
#> [1] "->" "of"
#>
get_prepositions(c("a [of b]", "d [-> e of f]"),
inf_notation = FALSE,
notation = bracket_notation)
#> $prepositions
#> [1] "of"
#>
#> $prepositions
#> [1] "->" "of"
#>
# Best to *not* specify notation by the preposition,
# as the result will be empty strings.
# Rather, give the notation as `bracket_notation`
# as shown above, or infer the notation
# as shown below.
get_prepositions(c("a [of b]", "d [-> e of f]"),
inf_notation = TRUE)
#> $prepositions
#> [1] "of"
#>
#> $prepositions
#> [1] "->" "of"
#>
# The suffix is extracted, and the preposition
# is lost before looking for the preposition.
get_prepositions(c("a [of b]", "d [of f]"),
inf_notation = FALSE,
notation = of_notation)
#> $prepositions
#> [1] ""
#>
#> $prepositions
#> [1] ""
#>