Analysis

Near Duplicates

Finds exact and near-duplicate documents in a text export (one .txt file per document, named by document ID), ignoring endorsed Bates-style stamps so re-produced copies still match.

PRO Command line: near-duplicates Version 1.0
A Pro toolIn the free edition it works on up to 25 documents per run, so you can try it on real work. Compare Free and Pro.

Near Duplicates compares the wording of documents rather than their files. It reads a text export where each document is a .txt file whose name is the document ID, removes endorsed stamps such as ABC.001.002.0003, and ignores case, punctuation and spacing. Documents whose remaining words are identical are grouped as exact duplicates; documents that share most of their wording are grouped as near duplicates.

Each near-duplicate group is built around a pivot, its longest document, and every member gets two scores against that pivot: Jaccard similarity (shared phrases as a share of all phrases in both) and containment (shared phrases as a share of the smaller document). Containment near 1 usually means one document is contained in the other, such as a draft and its extended final. This is a Pro tool: the free edition handles up to 25 documents per run.

Use it when

How to run it

  1. Prepare a text export with one .txt file per document, each named by its document ID (Extract Text can produce text files from natives).
  2. Choose the text folder as Input, and an Output folder outside it.
  3. If you know the production prefixes, enter them in prefixes; otherwise leave it empty.
  4. Leave threshold-percent at 80 for a first run.
  5. Click Run, then read the notes and open stamp-prefixes.csv before relying on the results.
  6. Use Open report and sort or filter by ExactDupGroup and NearDupGroup.

Settings

Every setting has the same help beside it in the app. On the command line, pass each as --name value; ltk help near-duplicates lists them.

Settings

SettingWhat it doesType and default
Threshold percent
--threshold-percent
How similar two documents must be to be grouped as near duplicates, as a percentage of shared wording (Jaccard similarity of their 5-word phrases). 80 is a good start; lower finds looser matches. 10 to 100.
The minimum Jaccard similarity to the pivot to join its group. Lower it (for example to 70) to catch looser versions; raise it to keep groups tight. Between 10 and 100.
number
80
Prefixes
--prefixes
Known production/Bates prefixes of the endorsed stamps to strip before comparing (e.g. ABC, SAI, 01072). Empty means any 2-10 letter/digit prefix followed by three dot-separated groups of 3-4 digits.
When empty, anything that looks like a stamp is removed: 2 to 10 letters or digits followed by three dot-separated groups of 3 or 4 digits (spaces around the dots allowed, case ignored). That can catch text that is not a stamp. Listing your real prefixes limits removal to those only.
list
empty
Min words
--min-words
Documents with fewer words than this are reported as Short and left out of near-duplicate grouping (they can still be exact duplicates).
Documents with fewer words are marked Short and left out of near-duplicate grouping, because very short texts match by chance. They can still be exact duplicates. Documents with no words after stamps are removed are marked Empty and are never grouped.
number
25
Max words
--max-words
Only the first this-many words of each document are used for near-duplicate comparison (the whole text is still used for exact duplicates). Longer documents are marked Truncated. 0 means no limit.
Limits near-duplicate comparison to the first part of very long documents (marked Truncated). The word count and exact-duplicate check still use the whole text. 0 means no limit.
number
500000
Shingle
--shingle
Words per phrase compared between documents. 5 suits most review sets; smaller values match more loosely. 1 to 50.
The phrase length compared. Smaller values match more loosely; 5 suits most sets.
number
5
Num perm
--num-perm
Size of each document's similarity fingerprint (MinHash permutations). Higher finds borderline matches more reliably but is slower. 16 to 1024; 128 is the usual choice.
Larger fingerprints find borderline matches more reliably but take longer. Final group membership is always confirmed with an exact similarity calculation.
number
128

Common settings

SettingWhat it doesType and default
Input required
--input
Folder (or single file) to read. It is opened read-only and never modified. folder
empty
Output required
--output
Folder for reports. Must not be inside the input folder. Each run gets its own sub-folder. folder
empty
Recurse
--recurse
Include sub-folders. yes/no
true
Extensions
--extensions
Only process these extensions (e.g. .pdf, .docx). Empty means the tool's default set. list
empty
Parallelism
--parallelism
Files processed at once. Use 1-2 for spinning disks or network shares. number
4

What you get

Each run creates its own folder inside the output folder, with the report near-duplicates.csv, errors.csv and manifest.json (see Run folders and manifests).

Report columns

Check the result

Tips
  • Exact copies of a document inherit its near-duplicate group, so the whole family appears together. An exact copy of the pivot shows IsPivot = N with a score of 1.000.
  • If the same file name appears in two folders, both are kept; ExactDupOf and NearDupPivot then show the relative path instead of the ID, and a note says so.
  • Text in UTF-8, UTF-16 or older Windows encodings is read correctly, so exports from different systems compare properly.
Watch out for
  • Only .txt files are read by default. Native documents must be converted to text first.
  • Similarity is about wording only. Two documents with the same text but different formatting, images or handwriting will match.
  • The input is never changed; the tool's working file is removed at the end of the run.

From the command line

The command line is part of LitTechKit Pro. See Command line.

ltk run near-duplicates --input "D:\Matter\Export\TEXT" --output "D:\Matter\Reports" --prefixes ABC,SAI --threshold-percent 80

Related tools