report_term_matches {lingmatch} | R Documentation |
Generate a Report of Term Matches
Description
Extract matches to fuzzy terms (globs/wildcards or regular expressions) from provided text, in order to assess their appropriateness for inclusion in a dictionary.
Usage
report_term_matches(dict, text = NULL, space = NULL, glob = TRUE,
parse_phrases = TRUE, tolower = TRUE, punct = TRUE, special = TRUE,
as_terms = FALSE, bysentence = FALSE, as_string = TRUE,
term_map_freq = 1, term_map_spaces = 1, outFile = NULL,
space_dir = getOption("lingmatch.lspace.dir"), verbose = TRUE)
Arguments
dict |
A vector of terms, list of such vectors, or a matrix-like object to be
categorized by |
text |
A vector of text to extract matches from. If not specified, will use the terms
in the |
space |
A vector space used to calculate similarities between term matches.
Name of a the space (see |
glob |
Logical; if |
parse_phrases |
Logical; if |
tolower |
Logical; if |
punct |
Logical; if |
special |
Logical; if |
as_terms |
Logical; if |
bysentence |
Logical; if |
as_string |
Logical; if |
term_map_freq |
Proportion of terms to include when using the term map as a source
of terms. Applies when |
term_map_spaces |
Number of spaces in which a term has to appear to be included.
Applies when |
outFile |
File path to write results to, always ending in |
space_dir |
Directory from which |
verbose |
Logical; if |
Value
A data.frame
of results, with a row for each unique term, and the following columns:
-
term
: The originally entered term. -
regex
: The converted and applied regular expression form of the term. -
categories
: Comma-separated category names, ifdict
is a list with named entries. -
count
: Total number of matches to the term. -
max_count
: Number of matches to the most representative (that with the highest average similarity) variant of the term. -
variants
: Number of variants of the term. -
space
: Name of the latent semantic space, if one was used. -
mean_sim
: Average similarity to the most representative variant among terms found in the space, if one was used. -
min_sim
: Minimal similarity to the most representative variant. -
matches
: Variants, with counts and similarity (Pearson's r) to the most representative term (if a space was specified). Either in the form of a comma-separated string or adata.frame
(ifas_string
isFALSE
).
Note
Matches are extracted for each term independently, so they may not align with some implementations
of dictionaries. For instance, by default lma_patcat
matches destructively, and sorts
terms by length such that shorter terms will not match the same text and longer terms that overlap.
Here, the match would show up for both terms.
See Also
For a more complete assessment of dictionaries, see dictionary_meta()
.
Similar information is provided in the dictionary builder web tool.
Other Dictionary functions:
dictionary_meta()
,
download.dict()
,
lma_patcat()
,
lma_termcat()
,
read.dic()
,
select.dict()
Examples
text <- c(
"I am sadly homeless, and suffering from depression :(",
"This wholesome happiness brings joy to my heart! :D:D:D",
"They are joyous in these fearsome happenings D:",
"I feel weightless now that my sadness has been depressed! :()"
)
dict <- list(
sad = c("*less", "sad*", "depres*", ":("),
happy = c("*some", "happ*", "joy*", "d:"),
self = c("i *", "my *")
)
report_term_matches(dict, text)