This script scrapes Wiktionary to find true cognate pairs by:
- Finding pages for reconstructed ancestor words (Proto-languages)
- Extracting descendant words from those pages
- Creating pairs of descendants as true cognates
Install the required dependencies:
pip install -r requirements_scraper.txtOr install individually:
pip install requests beautifulsoup4 lxmlRun the scraper:
python scrape_cognates.pyThe script will:
- Search for reconstructed words in Proto-Indo-European, Proto-Germanic, Proto-Slavic, Proto-Celtic, and Proto-Italic
- Extract descendant words from each reconstructed word page
- Create cognate pairs from descendants of the same ancestor
- Save results to
scraped_cognates.csv(in the format used byeval.py) andscraped_cognates.json(with detailed information)
You can modify the main() function to:
- Add more proto-languages to search
- Change the number of reconstructed words to check per language
- Adjust the minimum number of descendants required
Example:
cognate_pairs = scraper.scrape_cognate_pairs(
proto_languages=["Proto-Indo-European", "Proto-Germanic"],
num_words_per_language=20, # Check 20 reconstructed words per language
min_descendants=2 # Need at least 2 descendants to create pairs
)Compatible with your existing eval.py script:
input,target
English "brother" and German "Bruder",Yes
Latin "frater" and English "brother",YesDetailed information including:
- Proto-word and proto-language
- Both descendant words with their languages
- Original source information
- The script includes polite rate limiting (0.5-1 second delays between requests)
- Wiktionary's structure can vary, so parsing may not catch all descendants
- Some reconstructed words may have many descendants, others very few
- The script uses Wiktionary's API for searching and regular HTTP requests for page content