mecab-grpc

command module
v0.0.0-...-7ec22d8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 17, 2020 License: MIT Imports: 2 Imported by: 0

README

mecab-grpc

PkgGoDev

A server which provides Japanese tokenizing service over gRPC, powered with MeCab/NEologd.

Usage

[Server] Launch
$ docker built -t mecab-grpc .
....

$ docker run --rm -p 9000:9000 mecab-grpc
Listening on [::]:9000

You can edit /usr/local/etc/mecabrc to modify mecab's behavior.

Prebuilt image is also available on https://hub.docker.com/r/sekai/mecab-grpc

[Client] Tokenize over gRPC
$ go build
....

$ echo "ハロー、世界!" | ./mecab-grpc parse --remote localhost:9000
ハロー  名詞,一般,*,*,*,*,ハロー,ハロー,ハロー
、      記号,読点,*,*,*,*,、,、,、
世界    名詞,一般,*,*,*,*,世界,セカイ,セカイ
!      記号,一般,*,*,*,*,!,!,!
EOS
[Client] Embed in you app

This repository provides a Go API for communicating with mecab-grpc server. See pkg.go.dev or /mecabpb directory for detail.

You can also use /mecabpb/mecab.proto to generate gRPC codes for any other languages.

Example
package main

import (
	"context"
	"fmt"

	"github.com/kaz/mecab-grpc/mecabpb"
	"google.golang.org/grpc"
)

func main() {
	conn, err := grpc.Dial("localhost:9000", grpc.WithInsecure())
	if err != nil {
		panic(err)
	}
	defer conn.Close()

	client := mecabpb.NewMeCabClient(conn)
	resp, err := client.Parse(context.Background(), &mecabpb.ParseRequest{Input: "こんにちは、世界!"})
	if err != nil {
		panic(err)
	}

	fmt.Print(resp.Output)
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cli

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL