forked from PolMine/RcppCWB
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paths_attributes.Rd
More file actions
114 lines (104 loc) · 2.9 KB
/
Copy paths_attributes.Rd
File metadata and controls
114 lines (104 loc) · 2.9 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/cl.R
\name{CL: s_attributes}
\alias{CL: s_attributes}
\alias{cl_cpos2struc}
\alias{cl_struc2cpos}
\alias{cl_struc2str}
\alias{cl_cpos2lbound}
\alias{cl_cpos2rbound}
\title{Using Structural Attributes.}
\usage{
cl_cpos2struc(
corpus,
s_attribute,
cpos,
registry = Sys.getenv("CORPUS_REGISTRY")
)
cl_struc2cpos(
corpus,
s_attribute,
registry = Sys.getenv("CORPUS_REGISTRY"),
struc
)
cl_struc2str(
corpus,
s_attribute,
struc,
registry = Sys.getenv("CORPUS_REGISTRY")
)
cl_cpos2lbound(
corpus,
s_attribute,
cpos,
registry = Sys.getenv("CORPUS_REGISTRY")
)
cl_cpos2rbound(
corpus,
s_attribute,
cpos,
registry = Sys.getenv("CORPUS_REGISTRY")
)
}
\arguments{
\item{corpus}{name of a CWB corpus (upper case)}
\item{s_attribute}{name of structural attribute (character vector)}
\item{cpos}{An \code{integer} vector with corpus positions.}
\item{registry}{path to the registry directory, defaults to the value of the
environment variable CORPUS_REGISTRY}
\item{struc}{a struc identifying a region}
}
\description{
Structural attributes store the metadata of texts in a CWB
corpus and/or any kind of annotation of a region of text. The fundamental
unit are so-called strucs, i.e. indices of regions identified by a left and
a right corpus position. The corpus library (CL) offers a set of functions
to make the translations between corpus positions (cpos) and strucs
(struc).
}
\examples{
# get metadata for matches of token
# scenario: id of the texts with occurrence of 'oil'
token_to_get <- "oil"
token_id <- cl_str2id("REUTERS", p_attribute = "word", str = "oil", get_tmp_registry())
token_cpos <- cl_id2cpos("REUTERS", p_attribute = "word", id = token_id, get_tmp_registry())
strucs <- cl_cpos2struc("REUTERS", s_attribute = "id", cpos = token_cpos, get_tmp_registry())
strucs_unique <- unique(strucs)
text_ids <- cl_struc2str("REUTERS", s_attribute = "id", struc = strucs_unique, get_tmp_registry())
# get the full text of the first text with match for 'oil'
left_cpos <- cl_cpos2lbound(
"REUTERS", s_attribute = "id",
cpos = min(token_cpos),
registry = get_tmp_registry()
)
right_cpos <- cl_cpos2rbound(
"REUTERS",
s_attribute = "id",
cpos = min(token_cpos),
registry = get_tmp_registry()
)
txt <- cl_cpos2str(
"REUTERS", p_attribute = "word",
cpos = left_cpos:right_cpos,
registry = get_tmp_registry()
)
fulltext <- paste(txt, collapse = " ")
# alternativ approach to achieve same result
first_struc_match_oil <- cl_cpos2struc(
"REUTERS", s_attribute = "id",
cpos = min(token_cpos),
registry = get_tmp_registry()
)
cpos_struc <- cl_struc2cpos(
"REUTERS", s_attribute = "id",
struc = first_struc_match_oil,
registry = get_tmp_registry()
)
txt <- cl_cpos2str(
"REUTERS",
p_attribute = "word",
cpos = cpos_struc[1]:cpos_struc[2],
registry = get_tmp_registry()
)
fulltext <- paste(txt, collapse = " ")
}