Skip to content

Commit 8094da3

Browse files
committed
Avoiding importing multiple entries with same contents
1 parent 8994329 commit 8094da3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/import/AECD.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -164,11 +164,15 @@ export default async function importAECD(aecdPath, dbPath, fstPath, { report } =
164164

165165
}
166166

167-
for (const aecdEntry of unmatched) {
168-
if (aecdEntry.senses.length > 0) {
169-
dbIndex.add(new DatabaseEntry(aecdEntry))
167+
const candidates = Map.groupBy(unmatched, entry => entry.head.ae);
168+
169+
for (const aecdEntry of candidates.values()) {
170+
const possibleEntries = aecdEntry.filter(entry => entry.senses.length > 0)
171+
if (possibleEntries.length > 0) {
172+
dbIndex.add(new DatabaseEntry(possibleEntries[0]));
173+
entriesSkipped+=(aecdEntry.length-1);
170174
} else {
171-
entriesSkipped++;
175+
entriesSkipped+=aecdEntry.length;
172176
}
173177
}
174178

@@ -185,9 +189,9 @@ export default async function importAECD(aecdPath, dbPath, fstPath, { report } =
185189
console.info(`\n`);
186190
console.table({
187191
'Entries updated:': entriesUpdated,
188-
'Entries without a match (new):': unmatched.length,
189-
'Entries skipped (match without senses):': entriesSkipped,
190-
'Entries without a standardized lemma:': unstandardized.length,
192+
'Entries without a match (new):': unmatched.length-entriesSkipped,
193+
'Entries skipped:': entriesSkipped,
194+
'Entries without a standardized lemma:': unstandardized.length
191195
});
192196

193197
if (report) {

0 commit comments

Comments
 (0)