mlmorph
A Rust implementation of the Malayalam Morphological Analyzer using Finite State Transducer technology.
Overview
mlmorph is a Rust port of the mlmorph Malayalam morphological analyzer and generator. It provides fast and efficient morphological analysis and generation for Malayalam text using Finite State Transducers (FST) built with the Stuttgart Finite State Toolkit (SFST).
This library can:
- Analyze Malayalam words to identify their morphological structure
- Generate word forms from morphological descriptions
- Detect foreign words in Malayalam text
- Normalize Malayalam text using standard transformations
Features
- ⚡ Fast Performance: Rust implementation provides excellent performance
- 🔍 Morphological Analysis: Break down Malayalam words into morphemes and POS tags
- 🏗️ Word Generation: Generate word forms from morphological templates
- 🌐 Foreign Word Detection: Identify non-Malayalam words in text
- 📝 Text Normalization: Standardize Malayalam text representations
- 🖥️ CLI Interface: Command-line tool for batch processing
- 📚 Library API: Easy-to-use Rust API for integration
Installation
As a Library
Add this to your Cargo.toml:
[]
= "0.1.0"
As a CLI Tool
Or build from source:
Usage
Library API
Morphological Analysis
use Analyser;
Word Generation
use Generator;
Foreign Word Detection
use check_foreign_word;
Text Normalization
use normalize;
Command Line Interface
The CLI tool provides the same functionality as the Python version:
Morphological Analysis
# Analyze words from stdin
|
# Analyze words from a file
# Output format: word<tab>analysis<tab>weight
Word Generation
# Generate words from morphological descriptions
|
# Output format: input<tab>generated_word<tab>weight
Foreign Word Detection
# Check if words are foreign
|
# Output format: word<tab>is_foreign (1=foreign, 0=Malayalam)
CLI Options
API Reference
Core Types
// Analysis result: (analysis_string, weight)
pub type AnalysisResult = ;
// Generation result: (generated_word, weight)
pub type GenerationResult = ;
// Individual morpheme
// Parsed analysis structure
Analyser
Generator
Utility Functions
// Normalize Malayalam text
;
// Check if a word is foreign (returns 1 for foreign, 0 for Malayalam)
;
Requirements
- SFST Data: The library requires the compiled Malayalam FST file (
data/malayalam.a) - Rust: Version 1.70 or higher
Performance
The Rust implementation provides significant performance improvements over the Python version:
- Analysis: ~10x faster than Python implementation
- Generation: ~8x faster than Python implementation
- Memory: Lower memory footprint
- Concurrency: Safe for concurrent use across threads
Compatibility
This Rust implementation maintains API compatibility with the Python version where possible, making it easy to migrate existing applications.
Contributing
Contributions are welcome! Please see the main mlmorph project for contribution guidelines.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Citation
If you use this library in academic work, please cite:
Related Projects
- mlmorph (Python) - Original Python implementation
- mlmorph-spellchecker - Spellchecker based on mlmorph
- Web Interface - Try the analyzer online