Skip to content

Commit

Permalink
Started to ignore Word lock files
Browse files Browse the repository at this point in the history
  • Loading branch information
JBGruber committed Mar 30, 2021
1 parent 5908045 commit 80a319f
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 14 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Package: LexisNexisTools
Title: Working with Files from 'LexisNexis'
Version: 0.3.3.9000
Date: 2021-03-06
Date: 2021-03-30
Authors@R: person("Johannes", "Gruber", email = "[email protected]",
role = c("aut", "cre"))
Description: My PhD supervisor once told me that everyone doing newspaper
Expand Down
6 changes: 6 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# LexisNexisTools 0.3.4

* Fixes for compliance with quanteda v3 (thank you @kbenoit)
* All images for building the vignette now live inside the package
* `lnt_read_lines` and `lnt_read` now ignore Word lock files

# LexisNexisTools 0.3.3

* Updated namespacing for planned v3 modularisation of quanteda (thank you @kbenoit)
Expand Down
7 changes: 6 additions & 1 deletion R/LexisNexisTools.R
Original file line number Diff line number Diff line change
Expand Up @@ -1610,8 +1610,9 @@ lnt_lookup.character <- function(x,
#' LNToutput = lnt_read(lnt_sample(copy = FALSE)),
#' threshold = 0.97
#' )
#'
#' \dontrun{
#' lnt_diff(duplicates.df, min = 0.18, max = 0.30)
#' }
#' @author Johannes Gruber
#' @export
#' @importFrom quanteda tokens
Expand Down Expand Up @@ -2439,6 +2440,8 @@ lnt_read_lines <- function(files,
if (length(files$.doc) > 0) {
check_install("striprtf")
if (length(files$.doc) > 1) {
# ignore lock files
files$.doc <- files$.doc[!grepl("^~\\$", basename(files$.doc))]
lines_doc <- unlist(lapply(files$.doc, function(f) {
out <- striprtf::read_rtf(f)
names(out) <- rep(f, times = length(out))
Expand Down Expand Up @@ -2499,6 +2502,8 @@ lnt_read_lines <- function(files,
if (length(files$docx) > 0) {
check_install("xml2")
if (length(files$docx) > 1) {
# ignore lock files
files$docx <- files$docx[!grepl("^~\\$", basename(files$docx))]
lines_docx <- unlist(lapply(files$docx, function(f) {
con <- unz(description = f, filename = "word/document.xml")
out <- xml2::read_xml(con, encoding = "utf-8")
Expand Down
18 changes: 9 additions & 9 deletions Update package.R
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ spelling::spell_check_files("README.Rmd", ignore = readLines("./inst/WORDLIST"),
## Update Citation
update_citation <- function() {
cit <- readLines("./inst/CITATION")
note <- grep("note =", cit)
version <- grep("note = ", cit)
year <- grep("year = ", cit)

desc <- readLines("DESCRIPTION")
date <- desc[grepl("^Date:", desc)]
date2 <- gsub("[^[:digit:]-]", "", date)
desc[grepl("^Date:", desc)] <- gsub(date2, Sys.Date(), desc[grepl("^Date:", desc)])
vers <- desc[grepl("^Version:", desc)]
vers2 <- gsub("[^[:digit:].]", "", vers)
vers3 <- gsub("\\d+{3}", "", vers2)
vers3 <- gsub("[[:punct:]]$", "", vers3)
cit[note] <- gsub("\\d+.\\d+.\\d+", vers3, cit[note])
vers <- gsub("[^[:digit:].]", "", grep("^Version:", desc, value = TRUE))
cit[version] <- gsub("R package version (.*)", paste0("R package version ", vers), cit[version])

y <- gsub(".*(\\d{4}).*", "\\1", grep("^Date:", desc, value = TRUE))
cit[year] <- paste0(" year = ", y, ",")

writeLines(cit, "./inst/CITATION")
}
update_citation()
Expand Down
4 changes: 2 additions & 2 deletions inst/CITATION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bibentry(bibtype = "Manual",
title = "{L}exis{N}exis{T}ools. {A}n {R} package for working with newspaper data from '{LexisNexis}'",
author = as.person("Johannes Gruber"),
year = format(Sys.Date(), "%Y"),
year = 2021,
url = "https://github.com/JBGruber/LexisNexisTools",
note = "R package version 0.3.3"
note = "R package version 0.3.3.9000
)
3 changes: 2 additions & 1 deletion man/lnt_diff.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 80a319f

Please sign in to comment.