forked from PolMine/RcppCWB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths_attribute_decode.Rd
More file actions
64 lines (58 loc) · 1.97 KB
/
Copy paths_attribute_decode.Rd
File metadata and controls
64 lines (58 loc) · 1.97 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/decode.R
\name{s_attribute_decode}
\alias{s_attribute_decode}
\title{Decode Structural Attribute.}
\usage{
s_attribute_decode(
corpus,
data_dir,
s_attribute,
encoding = NULL,
registry = Sys.getenv("CORPUS_REGISTRY"),
method = c("R", "Rcpp")
)
}
\arguments{
\item{corpus}{A CWB corpus (ID in upper case).}
\item{data_dir}{The data directory where the binary files of the corpus are
stored.}
\item{s_attribute}{A structural attribute (length 1 \code{character} vector).}
\item{encoding}{Encoding of the values ("latin-1" or "utf-8")}
\item{registry}{The CWB registry directory.}
\item{method}{A length-one \code{character} vector, whether to use "R" or "Rcpp"
implementation for decoding structural attribute.}
}
\value{
A \code{data.frame} with three columns, if the s-attribute has
values, or two columns, if not. Column \code{cpos_left} are the start
corpus positions of a structural annotation, \code{cpos_right} the end
corpus positions. Column \code{value} is the value of the annotation.
}
\description{
Get \code{data.frame} with left and right corpus positions (cpos) for
structural attributes and values.
}
\details{
Two approaches are implemented: A pure R solution will decode the files
directly in the directory specified by \code{data_dir}. An implementation
using Rcpp will use the registry file for \code{corpus} to find the data
directory.
}
\examples{
# pure R implementation (Rcpp implementation fails on Windows in vanilla mode)
b <- s_attribute_decode(
corpus = "REUTERS",
data_dir = system.file(package = "RcppCWB", "extdata", "cwb", "indexed_corpora", "reuters"),
registry = get_tmp_registry(),
s_attribute = "places", method = "R"
)
# Using Rcpp wrappers for CWB C code
b <- s_attribute_decode(
corpus = "REUTERS",
data_dir = system.file(package = "RcppCWB", "extdata", "cwb", "indexed_corpora", "reuters"),
s_attribute = "places",
method = "Rcpp",
registry = get_tmp_registry()
)
}