dedup
zocrates.discovery.dedup ¶
In-memory deduplication and novelty filtering against local Zotero library and search batches.
CandidatePaper
dataclass
¶
CandidatePaper(candidate_id, title, authors=list(), year=None, venue=None, doi=None, arxiv_id=None, openalex_id='', abstract=None, tldr=None, is_oa=False, oa_pdf_url=None, oa_pdf_urls=list(), citation_count=0, primary_topic=None, keywords=list(), in_library=False)
Represents a discovered scholarly paper candidate.
from_dict
classmethod
¶
Deserialize CandidatePaper from a dictionary.
Source code in zocrates/discovery/models.py
to_dict ¶
Serialize CandidatePaper to a plain dictionary.
Source code in zocrates/discovery/models.py
Deduplicator ¶
Deduplicator(zotero_db=None, existing_dois=None, existing_arxiv_ids=None, existing_records=None, existing_titles=None)
Enforces strict novelty against the user's local Zotero library and removes duplicates within search result batches.
Initialize Deduplicator with library state from ZoteroDB or explicit collections.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zotero_db
|
Any | None
|
Optional ZoteroDB instance to query live library records. |
None
|
existing_dois
|
set[str] | None
|
Pre-populated set of normalized DOIs. |
None
|
existing_arxiv_ids
|
set[str] | None
|
Pre-populated set of normalized arXiv IDs. |
None
|
existing_records
|
list[dict[str, Any]] | None
|
Pre-populated list of library record dicts (with title, year, creators). |
None
|
existing_titles
|
list[str] | None
|
Pre-populated list of raw or normalized titles. |
None
|
Source code in zocrates/discovery/dedup.py
filter_novel ¶
Filter candidate papers enforcing strict novelty against the library and deduplicating across the current batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidates
|
list[CandidatePaper]
|
List of CandidatePaper instances. |
required |
Returns:
| Type | Description |
|---|---|
list[CandidatePaper]
|
List of strictly novel CandidatePaper instances, deduplicated intra-batch. |
Source code in zocrates/discovery/dedup.py
is_in_library ¶
Check whether candidate paper already exists in the user's library.
Evaluates
- DOI exact match.
- arXiv ID exact match.
- Exact normalized title match.
- Fuzzy title similarity (>= 0.92) with matching year or author.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
candidate
|
CandidatePaper
|
CandidatePaper instance. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
True if the paper exists in the library, False otherwise. |
Source code in zocrates/discovery/dedup.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 | |
normalize_arxiv_id ¶
Normalize an arXiv identifier by stripping URL prefixes, 'arxiv:' tags, and version suffixes.
Source code in zocrates/rag/zotero_db.py
normalize_doi ¶
Normalize DOI by stripping standard URI and resolver prefixes and lowercasing.
Source code in zocrates/rag/zotero_db.py
normalize_title ¶
Normalize paper title for fuzzy comparison by lowercasing, stripping punctuation, and normalizing whitespace.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str | None
|
Raw title string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Clean, lowercase, punctuation-free string. |