Remove repeated disambiguations (#1572)

This commit is contained in:
toasted-nutbread 2021-03-28 16:04:55 -04:00 committed by GitHub
parent b4d6a5d3b4
commit f58b4962f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -172,8 +172,19 @@ class DictionaryDataUtil {
}
const disambiguations = [];
if (!this._areSetsEqual(terms, allTermsSet)) { disambiguations.push(...this._getSetIntersection(terms, allTermsSet)); }
if (!this._areSetsEqual(readings, allReadingsSet)) { disambiguations.push(...this._getSetIntersection(readings, allReadingsSet)); }
const addTerms = !this._areSetsEqual(terms, allTermsSet);
const addReadings = !this._areSetsEqual(readings, allReadingsSet);
if (addTerms) {
disambiguations.push(...this._getSetIntersection(terms, allTermsSet));
}
if (addReadings) {
if (addTerms) {
for (const term of terms) {
readings.delete(term);
}
}
disambiguations.push(...this._getSetIntersection(readings, allReadingsSet));
}
return disambiguations;
}