cl_attribute_size: Get Attribute Size (of Positional/Structural Attribute).

Description Usage Arguments Examples

View source: R/RcppExports.R View source: R/cl.R

Description

Use cl_attribute_size to get the total number of values of a positional attribute (param attribute_type = "p"), or structural attribute (param attribute_type = "s"). Note that indices are zero-based, i.e. the maximum position of a positional / structural attribute is attribute size minus 1 (see examples).

Usage

1
2
cl_attribute_size(corpus, attribute, attribute_type,
  registry = Sys.getenv("CORPUS_REGISTRY"))

Arguments

corpus

name of a CWB corpus (upper case)

attribute

name of a p- or s-attribute

attribute_type

either "p" or "s", for structural/positional attribute

registry

path to the registry directory, defaults to the value of the environment variable CORPUS_REGISTRY

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
registry <- if (!check_pkg_registry_files()) use_tmp_registry() else get_pkg_registry()

Sys.setenv(CORPUS_REGISTRY = registry)
token_no <- cl_attribute_size("REUTERS", attribute = "word", attribute_type = "p")
corpus_positions <- seq.int(from = 0, to = token_no - 1)
cl_cpos2id("REUTERS", "word", cpos = corpus_positions)

places_no <- cl_attribute_size("REUTERS", attribute = "places", attribute_type = "s")
strucs <- seq.int(from = 0, to = places_no - 1)
cl_struc2str("REUTERS", "places", struc = strucs)

RcppCWB documentation built on Oct. 22, 2018, 5:08 p.m.