mecab_dart 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 65

mecab_dart #

MeCab(Japanese Morphological Analyzer) wrapper for Flutter on iOS/Android.

Usage #

  1. Add this plug_in mecab_dart as a dependency in your pubspec.yaml file.
dependencies:   
   mecab_dart: 0.1.2
  1. Copy Mecab dictionary (ipadic) to your assets folder

  2. Try the following example.

Example #

Init the tagger:

var tagger = new Mecab();
await tagger.init("assets/ipadic", true);

Set the boolean option in init function to true if you want to get the tokens including features, set it to false if you only want the token surfaces.

Use the tagger to parse text:

var tokens = tagger.parse('にわにわにわにわとりがいる。');
var text = '';

for(var token in tokens) {
  text += token.surface + "\t";
  for(var i = 0; i < token.features.length; i++) {
    text += token.features[i];
    if(i + 1 < token.features.length) {
       text += ",";
    }
  }
  text += "\n";
}

0.1.0 #

0.1.1 #

Update path_provider dependency to 1.6.5

#0.1.2

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:mecab_dart/mecab_dart.dart';

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  String text = "";
  var tagger = new Mecab();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String platformVersion;    
    try {
      platformVersion = await MecabDart.platformVersion;

      // Initialize mecab tagger here 
      //   + 1st parameter : dictionary asset folder
      //   + 2nd parameter : additional mecab options      
      await tagger.init("assets/ipadic", true);

      var tokens = tagger.parse('にわにわにわにわとりがいる。');

      for(var token in tokens) {
        text += token.surface + "\t";
        for(var i = 0; i < token.features.length; i++) {
          text += token.features[i];
          if(i + 1 < token.features.length) {
            text += ",";
          }
        }
        text += "\n";
      }
      //text = tokens.length.toString();

    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(text),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  mecab_dart: ^0.1.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:mecab_dart/mecab_dart.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
31
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
65
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Android

Because:

  • package:mecab_dart/mecab_dart.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform Linux

Because:

  • package:mecab_dart/mecab_dart.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:mecab_dart/mecab_dart.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:mecab_dart/mecab_dart.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform iOS

Because:

  • package:mecab_dart/mecab_dart.dart that imports:
  • package:path_provider/path_provider.dart that imports:
  • package:path_provider_linux/path_provider_linux.dart that declares support for platforms: Linux

Package does not support Flutter platform macOS

Because:

  • package:mecab_dart/mecab_dart.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • mecab_dart that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

30 out of 30 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/mecab_dart.dart.

Run flutter format to format lib/mecab_dart.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
ffi ^0.1.3 0.1.3
flutter 0.0.0
path_provider ^1.6.5 1.6.11
Transitive dependencies
collection 1.14.12 1.14.13
file 5.2.1
intl 0.16.1
meta 1.1.8 1.2.2
path 1.7.0
path_provider_linux 0.0.1+2
path_provider_macos 0.0.4+3
path_provider_platform_interface 1.0.2
platform 2.2.1
plugin_platform_interface 1.0.2
process 3.0.13
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
xdg_directories 0.1.0
Dev dependencies
flutter_test