detect_any {text2sdg} | R Documentation |
Detect SDGs in text with own query system
Description
detect_any
identifies SDGs in text using user provided query systems. Works like detect_sdg_systems
but uses a user specified query system instead of an existing one like detect_sdg_systems
does.
Usage
detect_any(
text,
system,
queries = lifecycle::deprecated(),
sdgs = NULL,
output = c("features", "documents"),
verbose = TRUE
)
Arguments
text |
|
system |
a data frame that must contain the following variables: a |
queries |
deprecated. |
sdgs |
|
output |
|
verbose |
|
Value
The function returns a tibble
containing the SDG hits found in the vector of documents. Depending on the value of output
the tibble will contain all or some of the following columns:
- document
Index of the element in
text
where match was found. Formatted as a factor with the number of levels matching the original number of documents.- sdg
Label of the SDG found in document.
- systems
The name of the query system that produced the match.
- query_id
Index of the query within the query system that produced the match.
- features
Concatenated list of words that caused the query to match.
- hit
Index of hit for a given system.
Examples
# create data frame with query system
my_queries <- tibble::tibble(
system = "my_system",
query = c(
"theory",
"analysis OR analyses OR analyzed",
"study AND hypothesis"
),
sdg = c(1, 2, 2)
)
# run sdg detection with own query system
hits <- detect_any(projects, my_queries)
# run sdg detection for sdg 2 only
hits <- detect_any(projects, my_queries, sdgs = 2)