R/util_find_abbreviations.R
util_find_abbreviations.RdDetects in-text abbreviation definitions and pairs each short form with its long form. Two kinds are found:
Parenthetical definitions, using the Schwartz & Hearst (2003) algorithm: "tumor necrosis factor (TNF)" and the reverse "TNF (tumor necrosis factor)".
Taxonomic abbreviations: "E. coli" paired with "Escherichia coli" when the full name also appears in the same unit.
Data frame or data.table with a text column and the identifier columns specified in by.
Character vector of identifier columns that define the text unit (e.g. doc_id or c("doc_id", "node_id")). Default c("doc_id").
Which detectors to run: "parenthetical",
"taxonomic", or both (default).
Data.table with by columns, short_form,
long_form, and method; one row per unique pair per unit.
Rows that share the same by values are pooled into one unit before
searching, so a definition in one paragraph pairs with a full name in
another. With by = "doc_id", node- or sentence-level rows from
read_urls or nlp_split_sentences are searched
as whole documents.
Schwartz, A. S., & Hearst, M. A. (2003). A simple algorithm for identifying abbreviation definitions in biomedical text. Pacific Symposium on Biocomputing, 451-462.
corpus <- data.frame(
doc_id = 1:2,
text = c("Levels of tumor necrosis factor (TNF) and interleukin-6 (IL-6) rose.",
"Escherichia coli was cultured. Growth of E. coli was slow.")
)
util_find_abbreviations(corpus, by = "doc_id")
#> doc_id short_form long_form method
#> <int> <char> <char> <char>
#> 1: 1 TNF tumor necrosis factor parenthetical
#> 2: 1 IL-6 interleukin-6 parenthetical
#> 3: 2 E. coli Escherichia coli taxonomic