dovmem
Swift · Python · JavaScript · SQLite FTS5Swift · Python · JavaScript · SQLite FTS5

بحث عربي ذكي. يلقى الكلمة مهما انكتبت.

Arabic Search. Finds the word however it was written.

البحث العادي يعامل «مذكرة» و«للمذكرة» و«بالمُذَكِّرة» كأنها كلمات مختلفة، فيضيع نص موجود قدامك. «بحث عربي ذكي» مكتبة Swift وPython وJavaScript تتجاهل التشكيل، وتوحّد الهمزات والألف والتاء المربوطة، وتلقى الكلمة ورا السوابق الملتصقة مثل ال ولل وبال وو وب. وهي نفس البحث اللي يشغّل dovmem.

Plain search treats «مذكرة», «للمذكرة» and «بالمُذَكِّرة» as different words, so text that is right there gets missed. Arabic Search is a Swift, Python and JavaScript library that ignores diacritics, unifies hamza, alef and taa marbuta forms, and finds words behind attached prefixes like ال, لل, بال, و and ب. It is the same search that powers dovmem.

جرّبهاTry it

اكتب كلمة وشوف الفرق

Type a word and see the difference

نفس الـ20 جملة في جدولين SQLite FTS5: واحد بالبحث العادي، وواحد بـ«بحث عربي ذكي».

The same 20 sentences in two SQLite FTS5 tables: one with plain search, one with Arabic Search.

البحث العاديPlain search SQLite FTS5 (unicode61)

    بحث عربي ذكيArabic Search

      التجربة هنا تشتغل على سيرفرنا عشان الصفحة بس. المكتبة نفسها تشتغل داخل تطبيقك بدون إنترنت.

      This demo runs on our server for this page only. The library itself runs inside your app, offline.

      قبل وبعدBefore and after

      وش يفوّت البحث العادي، ووش تلقى هي

      What plain search misses, and what this finds

      أمثلة توضيحية لطريقة المطابقة. وليش يصير كذا؟ اقرأ المقال: ليش البحث العربي في SQLite ما يلقى الكلمة.

      Illustrative examples of how matching works. Why does this happen? Read: why Arabic search in SQLite misses words.

      تبحث عنالبحث العادي يفوّتبحث عربي ذكي يلقى
      مذكرةللمذكرة، بالمُذَكِّرة، والمذكرهللمذكرة، بالمُذَكِّرة، والمذكره
      أحمداحمد، إحمداحمد، إحمد
      مستشفىمستشفي، بالمستشفى، وللمستشفىمستشفي، بالمستشفى، وللمستشفى
      مشروعبمشروع، ومشروعبمشروع، ومشروع
      سؤالسوال، السؤالسوال، السؤال
      You search forPlain search missesArabic Search finds
      مذكرةللمذكرة، بالمُذَكِّرة، والمذكرهللمذكرة، بالمُذَكِّرة، والمذكره
      أحمداحمد، إحمداحمد، إحمد
      مستشفىمستشفي، بالمستشفى، وللمستشفىمستشفي، بالمستشفى، وللمستشفى
      مشروعبمشروع، ومشروعبمشروع، ومشروع
      سؤالسوال، السؤالسوال، السؤال
      الكودCode

      سطرين وتبدأ

      A few lines to start

      مثال مختصر. التفاصيل الكاملة في التوثيق اللي يجي مع المكتبة.

      A short example. Full details are in the docs that come with the library.

      Swift
      import ArabicSearch
      
      // النص اللي تحفظه في عمود FTS5، وجملة البحث
      let stored = ArabicSearch.indexText("راجعت بالمُذَكِّرة أمس")
      let match  = ArabicSearch.ftsMatch("مذكرة")   // WHERE t MATCH ?
      
      let s = ArabicSearch.snippet("راجعت بالمُذَكِّرة أمس", query: "مذكرة")
      // s.highlights ← «بالمُذَكِّرة»
      Python
      import sqlite3, arabic_search as ar
      
      db = sqlite3.connect("notes.sqlite")
      ar.create_fts_table(db)                      # SQLite FTS5
      ar.index_row(db, 1, "راجعت بالمُذَكِّرة أمس")
      
      print(ar.search(db, "مذكرة"))                # [1]
      print(ar.snippet("راجعت بالمُذَكِّرة أمس", "مذكرة").highlights)
      JavaScript / TypeScript
      import { MemoryIndex } from "arabic-search-js/memory";   // في المتصفح
      import { ftsMatch } from "arabic-search-js";              // مع قاعدة البيانات
      
      const index = new MemoryIndex();
      index.add(1, "راجعت بالمُذَكِّرة أمس");
      index.search("مذكرة");                       // [1]
      ftsMatch("مذكرة");                           // WHERE t MATCH ?
      وش فيهاWhat's included

      كل اللي تحتاجه عشان البحث العربي يشتغل

      Everything you need for Arabic search that works

      بصراحةHonest limits

      وش ما تسويه

      What it does not do

      • ما فيها صرف كامل: تفصل السوابق الشائعة بس، وما تحلّل اللواحق مثل الضمائر والجموع (مذكرتي، مذكرات).
      • ما تستخرج الجذور: «كتب» ما تلقى «مكتبة» ولا «كاتب».
      • ما تعرف مرادفات اللهجات: «وش» ما تلقى «ماذا»، و«زين» ما تلقى «جيد».
      • No full morphology: it strips common prefixes only, and does not analyse suffixes such as pronouns and plurals (مذكرتي، مذكرات).
      • No root extraction: «كتب» does not find «مكتبة» or «كاتب».
      • No dialect synonyms: «وش» does not find «ماذا», and «زين» does not find «جيد».

      بحث عربي ذكيArabic Search

      $29

      مكتبات Swift وPython وJavaScript، مع الاختبارات والتوثيق.

      The Swift, Python and JavaScript libraries, with tests and docs.

      قريبًا. الشراء بيفتح هنا أول ما تجهز.

      Coming soon. Checkout opens here when it is ready.

      تبي توحيد النص بس (التشكيل والهمزات والتاء المربوطة)؟ فيه نسخة مجانية مفتوحة المصدر برخصة MIT: arabic-search-lite على GitHub.

      Only need normalization (diacritics, hamza, taa marbuta)? There is a free MIT version: arabic-search-lite on GitHub.

      أسئلةFAQ
      تحتاج إنترنت أو سيرفر؟Does it need the internet or a server?

      لا. كل شي يشتغل داخل تطبيقك: ما فيه طلبات شبكة ولا خدمة خارجية.

      No. Everything runs inside your app, with no network requests and no outside service.

      لازم أستخدم SQLite؟Do I have to use SQLite?

      الفهرس الجاهز مبني على SQLite FTS5، لكن دوال التوحيد وفصل السوابق تقدر تستخدمها لحالها مع أي محرك بحث.

      The ready index is built on SQLite FTS5, but the normalization and prefix functions can be used on their own with any search engine.

      هل تلخبط البحث بالإنجليزي؟Does it affect English search?

      لا. النص الإنجليزي والأرقام يتبحث فيهم مثل العادة، والمعالجة العربية تشتغل على الكلمات العربية بس.

      No. English text and numbers are searched as usual; the Arabic handling only applies to Arabic words.

      تلقى الكلمة وأنا لسا أكتبها؟Does it find words while I am still typing?

      إيه. أي كلمة في البحث تكفي بدايتها، فـ«التخ» تلقى «بمشروع التخرج»، ومع فصل السوابق بعد.

      Yes. The start of each word is enough, so «التخ» finds «بمشروع التخرج», prefixes included.