UNPKG

hadith-collections

Version:

A comprehensive npm package for searching and browsing hadith collections with Arabic and English support

79 lines (55 loc) 2.34 kB
# Hadith Database Analysis This script provides comprehensive analysis of the hadith database, giving you detailed insights into the collection structure, translation coverage, and statistics. ## Usage Run the analysis script: ```bash node analyze_data.js ``` ## What the Analysis Provides ### 1. **Hadith Counts per Collection** - Total number of Arabic hadiths in each collection - Breakdown by individual hadith collections ### 2. **English Translation Availability** - Number of hadiths with English translations per collection - Identifies which collections have translation gaps ### 3. **Translation Coverage** - Percentage coverage per collection (English/Arabic ratio) - Overall database translation coverage - Ranking of collections by translation completeness ### 4. **Books and Chapters Statistics** - Number of books per collection - Number of chapters per collection - Hierarchical structure analysis ## Output The script generates: 1. **Console Report**: A formatted, human-readable analysis displayed in the terminal 2. **JSON Export**: `hadith_analysis_report.json` - Machine-readable data for further processing ## Sample Results Based on the current database: - **16 Collections** total - **50,508 Arabic Hadiths** - **50,495 English Translations** - **99.97% Overall Translation Coverage** ### Top Collections by Size: 1. **Sahih Muslim** - 7,368 hadiths (100% translated) 2. **Sahih al-Bukhari** - 7,277 hadiths (100% translated) 3. **Sunan an-Nasa'i** - 5,768 hadiths (100% translated) 4. **Sunan Abi Dawud** - 5,276 hadiths (100% translated) ### Collection Structure Examples: - **Sahih al-Bukhari**: 97 books, 4,084 chapters - **Sahih Muslim**: 56 books, 1,348 chapters - **Mishkat al-Masabih**: 25 books, 641 chapters ## Technical Notes - Uses SQLite queries on `hadith_content` and `hadith_en_content` tables - Handles collections with no data gracefully - Exports detailed JSON for programmatic access - Calculates precise translation coverage percentages ## Requirements - Node.js - SQLite3 (via the existing project dependencies) - Access to `data/hadith.db` ## Error Handling The script includes comprehensive error handling: - Warns about collections that can't be accessed - Continues analysis even if individual collections fail - Provides detailed error messages for troubleshooting