Skip to content

Commit

Permalink
version 0.3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
SWinter committed Oct 19, 2022
1 parent 1c7cb87 commit 76b5d2b
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
Binary file modified papercheck-manual.pdf
Binary file not shown.
23 changes: 15 additions & 8 deletions papercheck.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Papercheck
-- Version 0.3.2 (2022/10/04)
-- Version 0.3.3 (2022/10/19)
-- By Simon Winter
-- https://github.com/ems-press/papercheck

Expand Down Expand Up @@ -149,9 +149,9 @@ for i = 1, #VarGreeks do
end
F.add_blankline()

-- Find double words:
F.patternsearch(texcode,"[^%a][Aa][%s\n~]+[Aa][^%a]", "Double word: A/a")
F.repeatedword(texcode)
-- Find duplicate words:
F.patternsearch(texcode,"[^%a][Aa][%s\n~]+[Aa][^%a]", "Duplicate word: A/a")
F.duplicatewords(texcode)
F.add_blankline()

local bibliography = texcode:match('(\\begin%s*{thebibliography}.-\\end%s*{thebibliography})')
Expand Down Expand Up @@ -245,7 +245,6 @@ local hyphenated = {
{"set", "theoretic"},
{"set", "up"},
{"simply", "connected"},
{"so", "called"},
{"square", "root"},
{"star", "shaped"},
{"straight", "forward"},
Expand All @@ -262,6 +261,14 @@ for i = 1, #hyphenated do
F.add_blankline()
end

local hyphenated_standalone = {
{"so", "called"}, -- Don't search for 'also called'.
}
for i = 1, #hyphenated_standalone do
F.hyphenatedsearch_standalone(texcode,hyphenated_standalone[i][1],hyphenated_standalone[i][2])
F.add_blankline()
end

local pattern_note = {
{"[^\\]%.[%s\n~]*\\end%b{}[%s\n~]*where", "'. \\end{...} where' found"},
{"[^\\]%.[%s\n~]*\\%][%s\n~]*where", "'. \\] where' found"},
Expand Down Expand Up @@ -327,7 +334,6 @@ local pattern_note = {
{"\\,%s*;", "\\,; --?--> ;"},
{"\\,%s*%.", "\\,. --?--> ."},
{",%s*\\cdots", ",\\cdots --?--> ,\\ldots"},
{"begin{aligned}[%s\n~]+%[", "No [ allowed after \\begin{aligned}. Write '\\begin{aligned}{} ['"},
{"\\section%s*{ ", "Do not use blank after \\section{"},
{"\\subsection%s*{ ", "Do not use blank after \\subsection{"},
{"\\subsubsection%s*{ ", "Do not use blank after \\subsubsection{"},
Expand All @@ -353,7 +359,8 @@ local pattern_note = {
{"er[%s\n~]+then", "[...]er then --?--> [...]er than"},
{"if[%s\n~]+follows", "if follows --?--> it follows"},
{"If[%s\n~]+follows", "If follows --?--> It follows"},
{"[iI]f[%s\n~]+and[%s\n~]+only[%s\n~]+[^i][^f]", "Probably second 'if' missing in 'if and only'"},
{"[iI]f[%s\n~]+and[%s\n~]+only[%s\n~]+[^i^%s^\n^~][^f^%s^\n^~]",
"Probably second 'if' missing in 'if and only'"},
{"it's", "it's --?--> 'it is' or 'its'"},
{"It's", "It's --?--> 'It is' or 'Its'"},
{"Let's", "Let's --?--> Let us"},
Expand All @@ -364,7 +371,7 @@ local pattern_note = {
{"can[%s\n~]+not", "can not --?--> cannot"},
{"the[%s\n~]+from", "the from --?--> the form"},
{"The[%s\n~]+from", "The from --?--> The form"},
{"form[%s\n~]+the", "form the --?--> from the"},
{"%Aform[%s\n~]+the", "form the --?--> from the"},
{"Form[%s\n~]+the", "Form the --?--> From the"},
{"Leibnitz", "Leibnitz --?--> Leibniz (Gottfried Wilhelm)"},
{"[%-–]+Schwartz", "Schwartz --?--> Schwarz (Cauchy--Schwarz)"},
Expand Down
19 changes: 15 additions & 4 deletions papercheckfunctions.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Papercheck (functions)
-- Version 0.3.1 (2022/08/05)
-- Version 0.3.3 (2022/10/19)
-- By Simon Winter
-- https://github.com/ems-press/papercheck

Expand Down Expand Up @@ -87,14 +87,18 @@ function M.recursivepatternsearch(text,pattern,note)
end
end

-- If repeated words of at least two letters are found in 'text', then return them.
function M.repeatedword(text)
-- If duplicate words of at least two letters are found in 'text', then return them.
function M.duplicatewords(text)
local finding = text:match('[^%a](%a%a+)[%s\n~]+%1[^%a]')
if finding then
blankline = true
print('Double word: '..finding)
-- Recursive:
M.repeatedword(text:gsub(M.escape_lua(finding),''))
M.duplicatewords(text:gsub(M.escape_lua(finding),'_'))
-- Note: If we replaced the double word with a space, new word duplications
-- could result. So we choose _. Example:
-- "The strongly monotone and monotone cases are explained and and proved."
-- --> "The strongly monotone _ monotone cases are explained _ _ proved."
end
end

Expand Down Expand Up @@ -124,6 +128,13 @@ function M.hyphenatedsearch(text,a,b)
M.inconsistencysearch(text,{capitalize(a)..b, capitalize(a)..'%-'..b, capitalize(a)..'[%s\n~]+'..b})
end

-- Similar to M.hyphenatedsearch, but no letter in front of 'a'.
function M.hyphenatedsearch_standalone(text,a,b)
M.inconsistencysearch(text,{'%A'..a..b, '%A'..a..'%-'..b, '%A'..a..'[%s\n~]+'..b})
M.inconsistencysearch(text,{'%A'..capitalize(a)..b, '%A'..capitalize(a)..'%-'..b,
'%A'..capitalize(a)..'[%s\n~]+'..b})
end

local function prefixsuffixsearch(text,prefixsuffix,patterns)
local finds = {}
for i = 1, #patterns do
Expand Down

0 comments on commit 76b5d2b

Please sign in to comment.