Corpus based Yoruba Translator. Uses Masakhane's data(plus other sources) to validate Yoruba syntax.
# Corpus NLP - Yoruba Sentence Validator
A Java-based natural language processing tool for the Yoruba language. It performs lexical analysis (tokenizing words and looking them up in a pre-built database of over 5,000 Yoruba words with POS tags, phonetics, and IPA), resolves ambiguity by matching diacritized forms, and validates sentence syntax against a large set of grammar rules.
## How it works
1. **Lexer** (`lexer.java`) - Loads `db.txt` into a HashMap. Strips diacritics and punctuations from user input via Unicode NFD normalization, then looks up each word. If a word has multiple POS entries (ambiguous), it checks the exact diacritized form to resolve.
2. **Parser** (`parser.java`) - Loads valid POS sequences from `syntax_rules.txt` into a HashSet. Builds a POS chain from the tokenized sentence and checks if it matches a known syntactic pattern.
3. **AmbiguityError** (`AmbiguityError.java`) - Custom exception for words that cannot be disambiguated.
## Test sentences
These Yoruba sentences can be used to test the program. Type them exactly as shown (with diacritics to prevent ambiguity):
**Success**
1. **Mo jẹ ẹja.**
2. **Wọn lọ.**
3. **Ó jẹ ounjẹ.**
**Failure**
1. **Mo jẹ ilé**
2. **Mi oku ku she she**