Case study · Applied AI · Information retrieval
JurisPortail — semantic search for Moroccan law
A retrieval system and mobile app that let people search French-language Moroccan legal articles by meaning rather than exact keywords.
Context: M.S. Software Engineering thesis, Al Akhawayn University in Ifrane, Summer 2023. Supervised by Dr. Asmae Mourhir.

Problem
- Moroccan legal texts are published online as PDF documents, so search is limited to keyword matching.
- Keyword matching misses the context and phrasing of legal language, which makes finding the right article slow for professionals, researchers and citizens.
My role
- Sole author of the thesis: data extraction, pre-processing, retrieval models, evaluation and the mobile application design.
Constraints
- No large labelled set of query–article pairs, which rules out supervised fine-tuning.
- Source PDFs vary in structure; documents with tables inside articles were excluded to keep extraction reliable.
- French legal vocabulary, where exact terms and their context both matter.
Architecture & approach
- Semi-automated extraction of 4,048 articles from six legal codes, including the Commercial Code, Labour Code, Penal Code and Code of Obligations and Contracts.
- French pre-processing pipeline (tokenisation, punctuation and stop-word removal, lemmatisation, accent cleaning) that roughly halved the token count.
- Three search approaches: BM25 and two variants (BM25L, BM25+), TF-IDF with Latent Semantic Indexing, and a hybrid combining BM25+ with TF-IDF/LSI.
- Similar-article recommendations from Sentence-CamemBERT embeddings indexed with ANNOY for approximate nearest-neighbour lookup.
- A React Native application on a Laravel backend for search, similar articles and relevance marking.
Key decisions
- Lexical and latent-semantic models over fine-tuned transformers for search, because they need no labelled training pairs.
- Transformer embeddings kept for recommendations, where similarity between whole articles matters more than exact terms.
- Evaluation combined Recall@8 and mean average precision with review by a legal domain expert and relevance marking by ten test users.
Outcome
- On the thesis evaluation set, the hybrid ranker reached the highest Recall@8 (0.92) and BM25+ the highest mean average precision (0.70).
- The domain expert approved BM25, BM25+, TF-IDF/LSI and the recommendation model, and rejected BM25L.
- These are offline research results, not production usage figures.
Stack
- Python
- BM25 / BM25+
- TF-IDF
- LSI
- Sentence-CamemBERT
- ANNOY
- React Native
- Laravel
Artifacts
Related work
- JurisPortail: Legal Semantic Search Engine — Digitlift
- JurisPortail: Mobile App — Digitlift