ropensci / spelling

Tools for Spell Checking in R
https://docs.ropensci.org/spelling
Other
107 stars 25 forks source link

spell_check_files: FOUND IN file name is mixed up when path isn't sorted #20

Closed kylebaron closed 5 years ago

kylebaron commented 5 years ago

I put MistakeA in fileA.txt and MistakeB in fileB.txt. When

path <- c("fileB.txt", "fileA.txt")

then spell_check_files(path) says MistakeA is found in fileB.txt and vice versa


library(spelling)

Create fileA.txt and fileB.txt

fileA <- '
store
car
MistakeA
road
'

fileB <- '
store
MistakeB
desk
road
'

writeLines(fileA, con = "fileA.txt")
writeLines(fileB, con = "fileB.txt")

files <- c("fileB.txt", "fileA.txt")

Check each file separately - FOUND IN is correct

l1 <- lapply(files, spell_check_files)
do.call("rbind", l1)
#>   WORD       FOUND IN
#> MistakeB   fileB.txt:3
#> MistakeA   fileA.txt:4

Check in one run - FOUND IN is mixed up

spell_check_files(files)
#>   WORD       FOUND IN
#> MistakeA   fileB.txt:4
#> MistakeB   fileA.txt:3

Sort then check in one run - FOUND IN is correct

spell_check_files(sort(files))
#>   WORD       FOUND IN
#> MistakeA   fileA.txt:4
#> MistakeB   fileB.txt:3

Created on 2019-02-02 by the reprex package (v0.2.1)

jeroen commented 5 years ago

🤔

jeroen commented 5 years ago

Good catch, thanks!!