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.
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
- You need to find drafts, versions and re-saved copies in a review set so they can be reviewed together or coded consistently.
- The same document was produced more than once with different Bates numbers and you need to find the repeats.
- Hash deduplication has been done but near-identical documents remain.
How to run it
- Prepare a text export with one
.txtfile per document, each named by its document ID (Extract Text can produce text files from natives). - Choose the text folder as Input, and an Output folder outside it.
- If you know the production prefixes, enter them in prefixes; otherwise leave it empty.
- Leave threshold-percent at 80 for a first run.
- Click Run, then read the notes and open
stamp-prefixes.csvbefore relying on the results. - 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
| Setting | What it does | Type 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. |
number80 |
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. |
number25 |
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. |
number500000 |
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. |
number5 |
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. |
number128 |
Common settings
| Setting | What it does | Type 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/notrue |
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. | number4 |
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).
near-duplicates.csv: One row per document, sorted by document ID: Status (OK, Short, Empty or ReadError), WordCount, Truncated, StampsRemoved, OwnIDInText, ExactDupGroup (EX000001 …) and ExactDupOf (the lowest document ID in the group), NearDupGroup (ND000001 …), NearDupPivot, IsPivot, JaccardToPivot and ContainmentToPivot (0 to 1, three decimals).stamp-prefixes.csv: Every stamp prefix that was removed and how many times, most common first.
Report columns
RelativePathDocIDStatusWordCountTruncatedStampsRemovedOwnIDInTextExactDupGroupExactDupOfNearDupGroupNearDupPivotIsPivotJaccardToPivotContainmentToPivot
Check the result
- Open
stamp-prefixes.csvand confirm every prefix is a genuine production prefix. If not, re-run with your real prefixes in prefixes. - Read the notes: the number of exact and near-duplicate groups, the count of each status and how many documents were truncated.
- Look at OwnIDInText: Y means a stamp in the text matches the document's own ID, N means stamps were found but none was its own ID (a possible mislabelled text file). It is blank where no stamps were found.
- Filter Status for ReadError and check
errors.csv.
- 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.
- Only
.txtfiles 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
- Extract Text: Extracts the text of PDF, Word, Excel, PowerPoint, email, RTF, HTML and text files into one UTF-8 .txt file per document, with page and sheet markers, and reports documents that need OCR.
- Deduplicate: Finds duplicate files by hash (and duplicate emails by their content), globally or per custodian. Reports every file as Unique, Master or Duplicate, and can copy out one copy of each.
- Email Threads: Groups emails into conversation threads by their reply headers, Outlook's conversation index and (optionally) reply subjects, and marks the inclusive emails: those not fully quoted in a later reply, so reviewing only them covers each conversation.
- Keyword Search: Searches PDF, Word, Excel, PowerPoint, email and text files for keywords (with wildcards) or regular expressions. Reports every hit with context, hits per term, and files that could not be searched.