init method
Initializes this mecab instance,
libmecabPath should be the path to a mecab dynamic library
Note: when using this package in Flutter, this parameter
can be null, and the library will be loaded from the
package's compiled mecab dynamic library.
dictDir should be a directory that contains a Mecab dictionary
(ex. IpaDic)
If includeFeatures is set, the output of mecab includes the
token-features.
Warning: This method needs to be called before any other method
Implementation
Future<void> init(String? libmecabPath, String dictDir, bool includeFeatures) async {
var options = includeFeatures ? "" : "-Owakati";
_mecabDartFfi = MecabDartFfi();
if(libmecabPath != null){
await _mecabDartFfi.init(libmecabPath: libmecabPath);
}
else{
await _mecabDartFfi.init(mecabFfiHelper: await loadMecabDartLib());
}
_mecabDartFfi.mecabDartFfiHelper.safeUsing((ffi.Arena arena) {
_mecabDartFfi.mecabPtr = _mecabDartFfi.initMecabFfi(
options.toNativeUtf8(), dictDir.toNativeUtf8());
});
this.libmecabPath = libmecabPath;
this.mecabDictDirPath = dictDir;
this.includeFeatures = includeFeatures;
}