Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Switch to Hybrid Google/Wiktionary Data Source
Summary
This PR implements a hybrid fallback strategy for dictionary definitions. The API now tries the original Google Dictionary endpoint first (preserving rich data like phonetics, origin, synonyms, antonyms), and falls back to Wiktionary when Google fails.
Motivation
The original Google Dictionary API endpoint started returning 400 Bad Request errors for some words, causing the API to fail. Rather than completely replacing Google with Wiktionary entirely, this hybrid approach:
Strategy
Changes
Core Changes
modules/dictionary.js:transformGoogle()andqueryGoogle()functionstransformWiktionary()andqueryWiktionary()functionsfindDefinitions()now tries Google first, falls back to WiktionarySupporting Changes
app.js:cleanText()to strip<style>and<script>tags from HTML contentDocumentation
README.md:API Response Comparison
wordphoneticphoneticsoriginmeaningsdefinitions[].synonymsdefinitions[].antonymsKey: ✅ = Data available, ⚪ = Empty placeholder (structure preserved)
Backward Compatibility
100% backward compatible. All API endpoints and response structure remain unchanged:
/api/v2/entries/en/{word}✅/api/v1/entries/en/{word}✅Testing
hellohellLondoncomputerNote: Google is currently returning 400 for all requests, so all queries fall back to Wiktionary. When/if Google resumes working, the API will automatically use the richer Google data.
License Compliance
Added proper attribution for Wiktionary content as required by CC-BY-SA 4.0:
Future Improvements
When someone wants to do a proper PR to enhance Wiktionary data extraction, they could: