get_piece: Get a piece of a label

View source: R/extractors.R

get_pieceR Documentation

Get a piece of a label

Description

This is a wrapper function for get_pref_suff(), get_nouns(), and get_objects(). It returns a piece of a row or column label.

Usage

get_piece(
  labels,
  piece = "all",
  notation = RCLabels::bracket_notation,
  prepositions = RCLabels::prepositions
)

Arguments

labels

The row and column labels from which prepositional phrases are to be extracted.

piece

The name of the item to return.

notation

The notation object that describes the labels. Default is RCLabels::bracket_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.

Details

piece is typically one of

  • "all" (which returns labels directly),

  • "pref" (for the prefixes),

  • "suff" (for the suffixes),

  • "noun" (returns the noun),

  • "pps" (prepositional phrases, returns prepositional phrases in full),

  • "prepositions" (returns a list of prepositions),

  • "objects" (returns a list of objects with prepositions as names), or

  • a preposition in prepositions (as a string), which will return the object of that preposition named by the preposition itself.

piece must be a character vector of length 1.

If a piece is missing in a label, "" (empty string) is returned.

Value

A piece of labels.

Examples

labs <- c("a [from b in c]", "d [of e in f]", "Export [of Coal from USA to MEX]")
get_piece(labs, "pref")
get_piece(labs, "suff")
get_piece(labs, piece = "noun")
get_piece(labs, piece = "pps")
get_piece(labs, piece = "prepositions")
get_piece(labs, piece = "objects")
get_piece(labs, piece = "from")
get_piece(labs, piece = "in")
get_piece(labs, piece = "of")
get_piece(labs, piece = "to")

RCLabels documentation built on March 18, 2022, 7:19 p.m.