Logo Lanfrica

4justo/NLP-Parser---Kiswhili

Domain:

natural language processingeducation

Record type:

software
Creator:
4ju
Host:
The Kiswahili Educational NLP Parser is a Natural Language Processing (NLP) project developed using Python and the Natural Language Toolkit (NLTK). It is designed to help junior secondary school learners understand Kiswahili sentence structure by parsing simple sentences # Kiswahili Educational NLP Parser ## Overview The Kiswahili Educational NLP Parser is a Natural Language Processing (NLP) project developed using Python and the Natural Language Toolkit (NLTK). It is designed to help junior secondary school learners understand Kiswahili sentence structure by parsing simple sentences and identifying the subject, verb phrase, object, and optional location phrase. Unlike a traditional CFG parser, this project follows a hybrid architecture used in industry by combining: - Context-Free Grammar (CFG) for syntax analysis - Semantic validation for meaning analysis This allows the system to reject sentences that are grammatically structured but semantically incorrect. --- ## Objectives - Design a formal Context-Free Grammar (CFG) for Kiswahili. - Parse simple educational Kiswahili sentences. - Generate parse trees. - Demonstrate valid and invalid sentence parsing. - Detect semantic errors using rule-based validation. - Evaluate the limitations of CFG in Kiswahili NLP. --- ## Features - CFG-based parser - Parse tree generation - Tokenizer - Semantic validation - Interactive terminal interface - Automated testing - Modular design --- ## Project Structure ``` Kiswahili-Educational-NLP-Parser/ │── parser.py │── grammar.cfg │── tokenizer.py │── semantic_rules.py │── run_tests.py │── test_cases.txt │── README.md │── requirements.txt │── report.pdf └── screenshots/ ``` --- ## Requirements Python 3.10+ Install dependencies ```bash pip install nltk ``` --- ## Running the Parser ```bash python parser.py ``` Example ``` Enter sentence: Mwanafunzi anasoma kitabu. ``` Output ``` CFG RESULT ✓ Sentence Structure Accepted SEMANTIC RESULT ✓ Passed Parse Tree Generated ``` --- ## Running Automated Tests ```bash python run_tests.py ``` --- ## Example Valid Sentences ``` Mwanafunzi anasoma kitabu. Mwalimu anaandika ubaoni. Mtoto anakula chakula. Wanafunzi wanasoma vitabu darasani. ``` --- ## Example Invalid Sentences ` …