Title: | Text Annotation App |
---|---|
Description: | Shiny-App that allows to annotate vectors of texts to predefined categories by hand. |
Authors: | Lukas Isermann [aut, cre] |
Maintainer: | Lukas Isermann <[email protected]> |
License: | Apache License (>= 2.0) |
Version: | 0.1.2 |
Built: | 2025-02-15 05:10:47 UTC |
Source: | https://github.com/liserman/handcoder |
'button_output' is an internal function to 'handcode'. It works within the Shiny-App 'handcoder_app' to format the look of the shiny::radioButtons.
button_output(classification, button, names = FALSE)
button_output(classification, button, names = FALSE)
classification |
Classification list obtained as list item from 'data_for_app' |
button |
Numerical value indicating for which button names and labels should be returned |
names |
Logical value indicating whether the function is supposed to return a formatted list of labels or a vector of names for use in radioButtons. |
Depending on the logical names input, the function returns a list of HTML formatted labels or the list of category names for the display of the radioButtons in the Shiny-App.
'character_to_data' is an internal function to 'handcode'. It takes a character vector of texts as well as an arg_list of named character vectors as inputs and returns a data frame which can be used as input to 'data_for_app'.
character_to_data(data, arg_list, missing)
character_to_data(data, arg_list, missing)
data |
A character vector of texts which has been given as data input to 'handcode'. |
arg_list |
A list of additional arguments which have been given as input to 'handcode'. These must be named character vectors of categories that will be used to annotate the given texts. |
missing |
A character vector of values that are displayed as missing values in the App. In the return data, these missing will be saved with an additional "_" as prefix and suffix. |
The function returns a data frame in the format of the output data frame that can be processed by the handcode() function.
'data_for_app' is an internal function to 'handcode'. It takes the inputs data, start, randomize and context to generate a list of inputs which can then be passed to 'handcoder_app'.
data_for_app(data, start, randomize, context, pre = NULL, post = NULL)
data_for_app(data, start, randomize, context, pre = NULL, post = NULL)
data |
A data frame that has been prepared by 'character_to_data' or that has previously already been returned from 'handcode'. |
start |
The value that has been given as start value to 'handcode'. |
randomize |
The logical value that has been given as randomize to 'handcode'. |
context |
The logical value that has been given as context to 'handcode'. |
pre |
Optional vector of texts that come before each respective text to be coded. |
post |
Optional vector of texts that come after each respective text to be coded. |
The function returns a list of inputs needed within the Shiny-App.
'gen_output' is an internal function to 'handcode'. It works within the Shiny-App 'handcoder_app' to prepare the output data frame.
gen_output(data, values)
gen_output(data, values)
data |
The data frame initially passed to 'handcoder_app' within a. |
values |
The values generated by the server of the 'handcoder_app'. |
The function returns a data frame with the coded variables.
'handcode' opens a Shiny-App which allows for hand coding strings of text into pre-defined categories. You can code between one and three variables at a time. It returns an updated data frame with your annotated classifications.
handcode( data, ..., start = "first_empty", randomize = FALSE, context = FALSE, missing = c("Not applicable"), pre = NULL, post = NULL )
handcode( data, ..., start = "first_empty", randomize = FALSE, context = FALSE, missing = c("Not applicable"), pre = NULL, post = NULL )
data |
A character vector of texts you want to annotate or a data frame returned from the handcode() function. |
... |
Between one and six named character vectors indicating different variables and categories you want to use for your annotation. Only needed if data a new character vector of texts. |
start |
A numeric value indicating the line in which you want to start hand coding. Alternatively, you can set start to "first_empty" to automatically start hand coding in the first line that has not been coded yet, or to "all_empty" to display all lines that have not been coded yet. |
randomize |
A logical value indicating whether you want to randomize the order in which texts are shown to the coder. |
context |
A logical value indicating whether you want the coder to see the previous and next text alongside the text that is currently coded. If TRUE, the function will show the previous and next text in light gray. This option is especially useful if we annotate individual sentences within a larger document. |
missing |
A character vector of values that are displayed as missing values in the App. In the return data, these missing will be saved with an additional "_" as prefix and suffix. |
pre |
Optional vector of custom texts that come as previous text before each respective text to be coded. Will be displayed if context = TRUE. This option can be used if the vector of texts specified in data do not form a continuous text. |
post |
Optional vector of custom texts that come as next text after each respective text to be coded. Will be displayed if context = TRUE. This option can be used if the vector of texts specified in data do not form a continuous text. |
The function returns a data frame containing all annotations that have been made in the Shiny-App.
reviews <- c("Good Quality Dog Food", "Not as Advertised", "Delight says it all", "Great! Just as good as the expensive brands") annotated <- handcode(reviews, evaluation = c("positive", "negative"))
reviews <- c("Good Quality Dog Food", "Not as Advertised", "Delight says it all", "Great! Just as good as the expensive brands") annotated <- handcode(reviews, evaluation = c("positive", "negative"))
'handcoder_app' is an internal function to 'handcode'. It provides a Shiny-App that allows users to click through different snippets of text and classify them manually according to predefined categories.
handcoder_app(a)
handcoder_app(a)
a |
A list containing all relevant information for the app to function. The list will be automatically generated by 'data_for_app'. |
The Shiny-App returns a data frame with the coded variables.