Multi-Language Search Engine
A powerful Flutter plugin for implementing multi-language search functionality with support for Arabic and English text, fuzzy matching, and typo tolerance.
Features
- 🔍 Multi-language support: Arabic and English text processing
- 🎯 Fuzzy search: Handles typos and similar words
- ⚡ Fast indexing: Inverted index for quick searches
- 🎨 Extensible architecture: Clean interfaces for customization
- 📱 Flutter integration: Easy to use in Flutter applications
- 🧪 Well-tested: Comprehensive test coverage
Installation
Add this to your pubspec.yaml
:
dependencies:
multi_language_search_engine: ^1.0.0
Then run:
flutter pub get
Quick Start
import 'package:multi_language_search_engine/multi_language_search_engine.dart';
void main() {
// Sample data
final data = [
{'id': 1, 'name': 'John Doe', 'description': 'Software Engineer'},
{'id': 2, 'name': 'Jane Smith', 'description': 'Product Manager'},
{'id': 3, 'name': 'أحمد محمد', 'description': 'مطور برمجيات'},
];
// Create search engine for English
final englishEngine = createSearchEngine(
data: data,
languageCode: 'en',
);
// Search
final results = englishEngine.search('software');
print('Found ${results.length} results');
// Create search engine for Arabic
final arabicEngine = createSearchEngine(
data: data,
languageCode: 'ar',
);
final arabicResults = arabicEngine.search('مطور');
print('Found ${arabicResults.length} Arabic results');
}
Advanced Usage
Custom Components
You can create custom implementations by implementing the interfaces:
class CustomNormalizer implements TextNormalizer {
@override
String normalize(String text) {
// Your custom normalization logic
return text.toLowerCase();
}
@override
bool get supportsArabic => false;
}
class CustomFactory implements SearchEngineFactory {
@override
TextNormalizer createNormalizer(String languageCode) {
return CustomNormalizer();
}
// Implement other factory methods...
}
Using Custom Factory
final customFactory = CustomFactory();
final searchEngine = createSearchEngine(
data: data,
languageCode: 'en',
factory: customFactory,
);
Language Support
English
- Case-insensitive search
- Punctuation removal
- Typo tolerance (a↔e, i↔y, etc.)
- Plural/singular variations
Arabic
- Diacritic removal (Tashkeel)
- Letter normalization (أ→ا, إ→ا, etc.)
- Arabic-specific typo variations
- Right-to-left text support
API Reference
SearchEngine Interface
abstract class SearchEngine {
List<Map<String, dynamic>> search(String query);
int get itemCount;
bool get isInitialized;
String get languageCode;
Future<void> initialize(List<Map<String, dynamic>> data);
}
Factory Methods
SearchEngine createSearchEngine({
required List<Map<String, dynamic>> data,
required String languageCode,
SearchEngineFactory? factory,
});
Performance
- Indexing: O(n) where n is the number of documents
- Search: O(k) where k is the number of matching documents
- Memory: Efficient inverted index structure
Testing
Run the tests:
flutter test
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Support
For questions and support:
- Create an issue on GitHub
- Check the documentation folder
- Review the example project
Libraries
- core/multi_language_search_engine
- factory/search_engine_factory
- implementations/arabic_normalizer
- implementations/english_normalizer
- implementations/similarity_calculator
- interfaces/search_engine
- multi_language_search_engine
- Multi-Language Search Engine Flutter Plugin
- multi_language_search_engine_method_channel
- multi_language_search_engine_platform_interface
- multi_language_search_engine_plugin
- multi_language_search_engine_web