compare_sentences: Flag differences between two text excerpts

View source: R/compare_sentences.R

compare_sentencesR Documentation

Flag differences between two text excerpts

Description

This function produces a LaTeX mark up that highlights text differences between two input sentences.

Usage

compare_sentences(
  sentence1,
  sentence2,
  highlight_diff = "underline",
  NA.string = c("n/a", "na", "N/A", "NA", "Not applicable", "not applicable",
    "Not Applicable")
)

Arguments

sentence1

Original text

sentence2

Revised text

highlight_diff

Font type used to highlight text differences. Defaults to underline. Other options are bold, italics, and standard.

NA.string

String defining characters recognised as "NA".

Value

A LaTeX formatted string showing text differences when rendered.

Author(s)

Phil J. Bouchet

Examples


library(respondR)
library(tidyverse)

compare_sentences(sentence1 = "My name is Patricia.", 
                 sentence2 = "My name is Stacey.", 
                 highlight_diff = "underline", 
                 NA.string = c("n/a", "na", "N/A", "NA"))
                
compare_sentences(sentence1 = "The sky is blue and the grass is green.", 
                 sentence2 = "The ocean is blue and the apples are green!",
                 highlight_diff = "underline", 
                 NA.string = c("n/a", "na", "N/A", "NA", "Not applicable",
                 "not applicable", "Not Applicable"))

compare_sentences(sentence1 = "My tailor is rich, 
                 and those flowers are beautiful!", 
                 sentence2 = "Their tailor is very wealthy, 
                 and these flowers are beautiful!",
                 highlight_diff = "underline", 
                 NA.string = c("n/a", "na", "N/A", "NA"))

pjbouchet/respondR documentation built on Feb. 7, 2023, 9:40 a.m.