
Alfanous - Quranic Search Engine
io.github.Alfanous-team由 GitHub 帳號 Alfanous-team 發布v1.9.4更新於 Oct 24, 2026
Search and explore the Holy Qur'an with Arabic text, transliteration, and advanced search support.
概覽
讓助理依阿拉伯文原文、轉寫、譯文、主題、位置或詞級語言學資訊檢索與瀏覽《古蘭經》。
- 可以做什麼
- 提供古蘭經檢索工具:search_quran、search_translations、search_quran_by_themes、search_quran_by_stats、search_quran_by_position、search_by_word_linguistics、suggest_query、correct_query、get_quran_info 與 list_field_values。支援簡單與布林查詢、片語、萬用字元、欄位、範圍與衍生層級檢索,並可依章、卷、赫茲布與主題進行分面彙總。結果可包含經文文字、譯文、誦讀與形態學標註。
- 適用情境
- 適合助理需要查找或引用古蘭經經文、依主題、位置或統計資訊定位經文、檢索譯文,或對文本進行形態學與語言學查詢的情境。它是參考資料檢索工具,不是通用網頁搜尋。
- 執行需求
- 在使用者機器上以 stdio 本機程序執行(僅桌面端)。安裝 PyPI 套件 alfanous3-mcp,並以 python -m alfanous_mcp.mcp_server 啟動。未宣告驗證、環境變數或標頭。選用詞幹處理需要 pystemmer 套件;新增譯文需要 alfanous_import 套件。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 Alfanous - Quranic Search Engine,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
Alfanous API
Alfanous is a Quranic search engine API that provides simple and advanced search capabilities for the Holy Qur'an. It enables developers to build applications that search through Quranic text in Arabic, with support for Buckwalter transliteration, advanced query syntax, and rich metadata.
Features
- Powerful Search: Search Quranic verses with simple queries or advanced Boolean logic
- Arabic Support: Full support for Arabic text and Buckwalter transliteration
- Rich Metadata: Access verse information, translations, recitations, and linguistic data
- Flexible API: Use as a Python library or RESTful web service
- Faceted Search: Aggregate results by Sura, Juz, topics, and more
- Multiple Output Formats: Customize output with different views and highlight styles
Quickstart
Installation
Install from PyPI using pip:
Basic Usage
Python Library
Web Service
You can also use the public web service:
- Search: http://alfanous.org/api/search?query=الله
- With transliteration: http://alfanous.org/api/search?query=Allh
Or run your own web service locally (see alfanous_webapi).
Quick Examples
Search for phrases:
Boolean search (AND, OR, NOT):
Fielded search:
Wildcard search:
Faceted search (aggregate by fields):
Documentation
API Reference
Core Functions
api.search(query, **options)- Search Quran versesapi.do(params)- Unified interface for all actions (search, suggest, show, list_values, correct_query)api.correct_query(query, unit, flags)- Get a spelling-corrected version of a queryapi.get_info(category)- Get metadata information
The underlying Raw output engine is exposed as Engine in alfanous.api (and re-exported from alfanous directly). Use it as a context manager to ensure index resources are properly released:
Search Parameters
Common parameters for api.do() with action="search":
query(str): Search query (required)unit(str): Search unit - "aya", "word", or "translation" (default: "aya")page(int): Page number (default: 1)perpage(int): Results per page, 1-100 (default: 10)sortedby(str): Sort order - "score", "relevance", "mushaf", "tanzil", "ayalength" (default: "score")reverse(bool): Reverse the sort order (default: False)view(str): Output view - "minimal", "normal", "full", "statistic", "linguistic" (default: "normal")highlight(str): Highlight style - "css", "html", "bold", "bbcode" (default: "css")script(str): Text script - "standard" or "uthmani" (default: "standard")vocalized(bool): Include Arabic vocalization (default: True)translation(str): Translation ID to includerecitation(str): Recitation ID to include (1-30, default: "1")fuzzy(bool): Enable fuzzy search — searches bothaya_(exact) andaya(normalised/stemmed) fields, plus Levenshtein distance matching (default: False). See Exact Search vs Fuzzy Search.fuzzy_maxdist(int): Maximum Levenshtein edit distance for fuzzy term matching —1,2, or3(default:1, only used whenfuzzy=True).facets(str): Comma-separated list of fields for faceted searchfilter(dict): Filter results by field values
For a complete list of parameters and options, see the detailed documentation.
Advanced Features
Exact Search vs Fuzzy Search
Alfanous provides two complementary search modes that control which index fields are queried.
Exact Search (default — fuzzy=False)
When fuzzy search is off (the default), queries run against the aya_ field, which stores the fully-vocalized Quranic text with diacritical marks (tashkeel) preserved. This mode is designed for precise, statistical matching:
- Diacritics in the query are significant —
مَلِكِandمَالِكِare treated as different words. - No stop-word removal, synonym expansion, or stemming is applied to the query.
- Ideal when you need exact phrase matches, reproducible result counts, or statistical analysis.
Fuzzy Search (fuzzy=True)
When fuzzy search is on, queries run against both the aya_ field (exact matches) and the aya field (a separate index built for broad, forgiving search). At index time the aya field is processed through a richer pipeline:
- Normalisation — shaped letters, tatweel, hamza variants and common spelling errors are unified.
- Stop-word removal — high-frequency function words (e.g. مِنْ، فِي، مَا) are filtered out so they do not dilute result relevance.
- Synonym expansion — each token is stored together with its synonyms, so a query for one word automatically matches equivalent words.
- Arabic stemming — words are reduced to their stem using the Snowball Arabic stemmer (via
pystemmer), so different morphological forms of the same root match each other.
No heavy operations are performed on the query string at search time; all the linguistic enrichment lives in the index.
Additionally, for each Arabic term in the query, a Levenshtein distance search is performed against the aya_ac field (unvocalized, non-stemmed). This catches spelling variants and typos within a configurable edit-distance budget controlled by fuzzy_maxdist.
Fuzzy mode is particularly useful when:
- The user does not know the exact vocalized form of a word.
- You want morphologically related words to appear in the same result set (e.g. searching كتب also surfaces كتاب, كاتب, مكتوب).
- You want synonym-aware retrieval without writing explicit OR queries.
Note:
pystemmermust be installed for stemming to take effect (pip install pystemmer). If the package is absent the stem filter degrades silently to a no-op, leaving normalisation and stop-word removal still active.
List Field Values
list_values returns every unique indexed value for a given field. Use it to discover the full vocabulary of searchable fields — for example, all available translation identifiers, part-of-speech tags, or root words — before composing a query.
Parameters:
field(str): The name of the indexed field whose unique values you want (required).
Return value:
A dictionary with a list_values key containing:
field— the requested field name.values— sorted list of unique non-empty indexed values.count— length of thevalueslist.
Query Correction
correct_query() uses Whoosh's built-in spell-checker to compare each term in the query against the index vocabulary and replace unknown terms with the closest known alternative. When the query is already valid (all terms appear in the index) the corrected value in the response is identical to the original input.
Parameters:
query(str): The raw query string to correct (required).unit(str): Search unit — currently only"aya"is supported; other units returnNone(default:"aya").flags(dict): Optional dictionary of additional flags.
Return value:
A dictionary with a correct_query key containing:
original— the input query string as provided.corrected— the corrected query string; identical tooriginalwhen no correction is needed.
Query Syntax
Alfanous supports advanced query syntax:
- Phrases: Use quotes -
"الحمد لله" - Boolean AND: Use
+-الصلاة + الزكاة - Boolean OR: Use
|-الصلاة | الزكاة - Boolean NOT: Use
--الصلاة - الزكاة - Wildcards: Use
*for multiple chars,?for single char -*نبي*,نعم؟ - Fielded Search: Use field name -
سورة:يس,سجدة:نعم - Ranges: Use
[X الى Y]-رقم_السورة:[1 الى 5] - Partial Vocalization: Search with some diacritics -
آية_:'مَن' - Derivation (stem): Use
>->رحيم(searchesaya_stem— corpus-derived stem) - Derivation (lemma): Use
>>->>رحيم(searchesaya_lemma— all inflections of the same lexeme) - Derivation (root): Use
>>>->>>ملك(searchesaya_root— all words from the same root) - Tuples: Use
{root,type}-{قول،اسم}
Derivation-Level Search
Control how broadly the search expands morphologically using the derivation_level parameter:
Each derivation field is pre-indexed at build time so queries run against a compact, pre-computed representation rather than expanding at search time.
The derivation syntax >word, >>word, >>>word maps to levels 1, 2, 3 respectively and can be embedded directly in queries:
Word Search (unit="word")
When unit="word" the engine searches word-level child documents instead of verse-level parent documents. Each word child carries its full morphological annotation — part-of-speech, lemma, stem, root, pattern, gender, number, person, voice, mood, derivation level, and more.
Morphological Filtering (search_by_word_linguistics)
Filter words by any combination of morphological properties using the search_by_word_linguistics action:
Available morphological filter fields include: pos, type, root, lemma, stem, pattern, gender, number, person, voice, mood, state, case, form, aspect, derivation, special, prefix, suffix, segments.
Faceted search allows you to aggregate search results by fields:
Available facet fields:
sura_id- Sura (chapter) number (1-114)juz- Juz (part) number (1-30)hizb- Hizb (section) numberchapter- Main topic/chaptertopic- Subtopicsura_type- Meccan/Medinan classification
Filtering Results
Filter search results by field values:
Search Fields
Available fields for fielded search:
سورة(sura) - Sura nameرقم_السورة(sura_id) - Sura numberرقم_الآية(aya_id) - Verse numberجزء(juz) - Juz numberحزب(hizb) - Hizb numberصفحة(page) - Page number in Mushafسجدة(sajda) - Has prostrationموضوع(subject) - Subject/themeفصل(chapter) - Chapterباب(subtopic) - Subtopicنوع_السورة(sura_type) - Sura type (Meccan/Medinan)
Word-level fields (use with unit="word"):
englishstate- Nominal state in English (e.g. "Definite state", "Indefinite state")englishmood- Verb mood in English (e.g. "Indicative mood", "Subjunctive mood", "Jussive mood")
For the complete field list, call:
Output Views
Different views provide different levels of detail:
- minimal - Basic verse text and identifier
- normal - Verse text with essential metadata
- full - All available information
- statistic - Include statistical information
- linguistic - Include linguistic analysis
Example:
Metadata Access
Get various metadata using the "show" action:
Note: Lemmas are no longer exposed via
show. Useapi.do({"action": "list_values", "field": "lemma"})to retrieve them on demand.
Adding New Translations
You can extend the local search index with additional Zekr-compatible .trans.zip translation files using index_translations(). This requires the alfanous_import package (included in the repository under src/alfanous_import/).
The function:
- Iterates over every
*.trans.zipfile insource - Skips translations that are already in the index (idempotent — safe to call repeatedly)
- Returns the count of newly indexed translations (
0means nothing new was added) - Automatically updates
configs/translations.jsonso the new translations are immediately visible viaapi.get_info("translations")and searchable withunit="translation"
After indexing, search in the new translation:
See examples/index_translations_example.py for a complete walkthrough.
Examples
The examples/ directory contains example scripts demonstrating various features:
- facet_search_examples.py - Faceted search and filtering examples
See examples/README.md for more information.
MCP Server
Alfanous ships an MCP (Model Context Protocol) server that lets AI assistants (Claude, Copilot, etc.) search and explore the Qur'an directly. See alfanous_mcp/README.md for the full reference.
Quick start:
To connect Claude Desktop, add the following to your claude_desktop_config.json:
Web Interface
Alfanous includes a FastAPI-based web service for RESTful access. See alfanous_webapi/README.md for:
- Installation and setup
- API endpoints
- Request/response examples
- Interactive API documentation (Swagger UI)
Quick start:
Then visit http://localhost:8000/docs for interactive documentation.
Contributing
We welcome contributions! See CONTRIBUTING.md for:
- Setting up a development environment
- Building from source
- Running tests
- Submitting pull requests
- Code style guidelines
Quick development setup:
Support
- GitHub Issues: https://github.com/Alfanous-team/alfanous/issues
- Mailing List: [email protected]
- Website: http://alfanous.org
License
Alfanous is licensed under the GNU Lesser General Public License v3 or later (LGPLv3+).
See LICENSE for details.
Credits
- Contributors: See AUTHORS.md and THANKS.md
This project handles sacred religious text (the Holy Qur'an) - please treat the data and code with respect.
Legacy
If you are looking for the legacy Alfanous code, you can find it under the legacy branch.
來源:README.md,提交 c2a7cfd
工具
0版本歷史
1- v1.9.4最新Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分