get_diff {wikkitidy} | R Documentation |
Search for insertions, deletions or relocations of text between two versions of a Wikipedia page
Description
Any two revisions of a Wikipedia page can be compared using the 'diff' tool. The tool compares the 'from' revision to the 'to' revision, looking for insertions, deletions or relocations of text. This operation can be performed in any order, across any span of revisions.
Usage
get_diff(from, to, language = "en", simplify = TRUE)
Arguments
from |
Vector of revision ids |
to |
Vector of revision ids |
language |
Vector of two-letter language codes (will be recycled if length==1) |
simplify |
logical: should R simplify the result (see return) |
Value
The return value depends on the simplify
parameter.
If
simplify
== TRUE: A list of tibble::tbl_df objects the same length asfrom
andto
. Most of the response data is stripped away, leaving just the textual differences between the revisions, their location, type and 'highlightRanges' if the textual differences are complicated.If
simplify
== FALSE: A list the same length asfrom
andto
containing the full wikidiff2 response for each pair of revisions. This response includes additional data for displaying diffs onscreen.
Examples
# Compare revision 847170467 to 851733941 on English Wikipedia
get_diff(847170467, 851733941)
# The function is vectorised, so you can compare multiple pairs of revisions
# in a single call
# See diffs for the last two revisions of the Main Page
revisions <- wiki_action_request() %>%
query_by_title("Main Page") %>%
query_page_properties(
"revisions",
rvlimit = 2, rvprop = "ids", rvdir = "older"
) %>%
next_result() %>%
tidyr::unnest(cols = c(revisions)) %>%
dplyr::mutate(diffs = get_diff(from = parentid, to = revid))
revisions