Skip to content

[MEDIUM] feat: Add subject-based (thematic) search #89

Description

@adelpro

Content:

Today, semantic search in src/core/layers/semantic-search.ts only expands to a flat list of synonyms from src/data/semantic.json. Searching for "climate" returns nothing because the engine has no concept of themes — rain, wind, tornadoes are not connected.

Add a subject search mode (options.subject = true) backed by a curated subject graph: each node groups related Arabic lemmas/roots by theme (weather, emotions, family, worship, etc.).

Requirements:

  • New JSON file src/data/subjects.json (ships an initial seed/template — see issue [Easy] Sura Metadata Constants #2).
    -New loader loadSubjectData() exported from src/index.ts.
  • Add subjectMap?: Map<string, SubjectNode> to SearchContext.
  • Add subjectIndex?: Map<string, Set> to InvertedIndex, built by buildInvertedIndex.
  • New performSubjectSearch() in src/core/layers/.
  • Score hits with matchType: 'subject' (also add to MatchType union and SearchCounts).
    Example:
search('climate', { /* ... */ subjectMap }, { subject: true });
// returns verses containing أمطار، رياح، عواصف، بروق، رعد، سحاب ...
Files / Links:

https://github.com/adelpro/quran-search-engine/blob/main/src/core/layers/semantic-search.ts
https://github.com/adelpro/quran-search-engine/blob/main/src/data/semantic.json
https://github.com/adelpro/quran-search-engine/blob/main/src/utils/loader.ts
https://github.com/adelpro/quran-search-engine/blob/main/src/types/index.ts
https://github.com/adelpro/quran-search-engine/blob/main/src/core/search.ts
https://github.com/adelpro/quran-search-engine/blob/main/src/index.ts
https://github.com/adelpro/quran-search-engine/blob/main/README.md

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions