macomp

package module
v0.0.0-...-804a06b Latest Latest
Warning

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

Go to latest
Published: May 11, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

README

macomp: Morphological Analyzer Comparator

CircleCI Report card GoDoc Apache License

Usage

Initialize

First, initialize ~/.macomp.json to run the following command.

macomp --init

Modify it if you need.

macomp

See macomp -h for the detail.

$ macomp
宇宙にあるいて座
juman          |宇 宙|に|あ る い て|座|
jumanpp        |宇 宙|に|あ る い て|座|
mecab-ipa-NE   |宇 宙|に|あ る|い て 座|
mecab-unidic   |宇 宙|に|あ る い|て|座|

$ macomp --pos --check
宇宙にある|いて?座|
X juman          |宇 宙|に|あ る_い て|座|
                 |名   |助|動         |名|
X jumanpp        |宇 宙|に|あ る_い て|座|
                 |名   |助|動         |名|
O mecab-ipa-NE   |宇 宙|に|あ る|い て 座|
                 |名   |助|動   |名      |
X mecab-unidic   |宇 宙|に|あ る_い/て|座|
                 |名   |助|動      |助|名|

$ macomp -t jumanpp -t mecab-ipa-NE
柱で食べるジャパリまんは美味しい
jumanpp      |柱|で|食 べ る|ジ ャ パ リ|ま ん|は|美 味 し い|
mecab-ipa-NE |柱|で|食 べ る|ジ ャ|パ リ|ま|ん|は|美 味 し い|
macomp-server
macomp-server

Open localhost:5000 and use the form, or use commands.

curl http://localhost:5000/api/v1/ma/食べたい
curl -X POST -d 'text=食べたい' http://localhost:5000/api/v1/ma
curl -X POST -d 'text=食べたい' -d 'callback=jsonp123' http://localhost:5000/api/v1/ma

See macomp-server -h for the detail.

Install

Macomp requires the following packages.

JUMAN and JUMAN++ are optional.

Golang
sudo apt-get install golang
echo 'export GOPATH=~/.go; export PATH=$PATH:$GOPATH/bin' >> ~/.bashrc
soruce ~/.bashrc
MeCab
sudo apt-get install mecab libmecab-dev

You can also install from the source codes.

git clone git@github.com:taku910/mecab.git --depth 1
cd mecab/mecab
autoreconf -i
./configure --with-charset=utf8 --enable-utf8-only
make
sudo make install
sudo ldconfig

cd ../mecab-ipadic
./configure --with-charset=utf8
make
sudo make install
macomp
export CGO_LDFLAGS="`mecab-config --libs`"
export CGO_CFLAGS="-I`mecab-config --inc-dir`"
go get github.com/FairyDevicesRD/macomp/cmd/macomp
go get github.com/FairyDevicesRD/macomp/cmd/macomp-server

Configure

macomp --init
vi ~/.macomp.json
  • type is a mandatory field
  • path, aliases and options are not mandatory fields.
  • Set disable to true if you want to disable the setting
  • Be aware to use absolute path

License

Documentation

Index

Constants

View Source
const Blank = " "

Blank is an expression for a non segment

View Source
const IllegalSegment = "/"

IllegalSegment is an expression for an illegal segment

View Source
const IllegalUnsegment = "_"

IllegalUnsegment is an expression for an illegal unsegmented position

View Source
const Segment = "|"

Segment is an expression for a valid segment

Variables

This section is empty.

Functions

func DecorateSurfaces

func DecorateSurfaces(text string, surfs []string) (string, bool)

DecorateSurfaces returns a decorated line

func GetConfigPath

func GetConfigPath() string

GetConfigPath returns config file path

func GetConstraints

func GetConstraints(query string) (IntSet, IntSet, IntSet, int, int)

GetConstraints returns segmentation information

func GetStaticRootPath

func GetStaticRootPath() string

GetStaticRootPath returns the static root path

func PrettyFeatures

func PrettyFeatures(surfs []string, features []string) string

PrettyFeatures returns a pretty line

func PrettySurfaces

func PrettySurfaces(surfs []string) string

PrettySurfaces returns a pretty line

func PrintDefaultPath

func PrintDefaultPath()

PrintDefaultPath prints default paths

Types

type IntSet

type IntSet map[int]struct{}

IntSet is a set of int

func GetSegments

func GetSegments(surfs []string) IntSet

GetSegments returns segment positions

func (IntSet) Add

func (is IntSet) Add(v int)

Add addes a value

type MaResource

type MaResource struct {
	Mecabs map[string]*mecab.MeCab
	Jumans map[string]*jk.Juman
}

MaResource contains resources related the server

func NewMaResource

func NewMaResource(settings map[string]MaSetting) (*MaResource, error)

NewMaResource returns MaResource

func (*MaResource) Destroy

func (mr *MaResource) Destroy()

Destroy all objects

func (*MaResource) Parse

func (mr *MaResource) Parse(text string) []MaResult

Parse returns results

type MaResult

type MaResult struct {
	Name     string
	Surfaces []string
	Features []string
	Error    error
}

MaResult is a result store

func NewMaResult

func NewMaResult(name string, node *mecab.Node, err error) *MaResult

NewMaResult returns MaResult

type MaSetting

type MaSetting struct {
	MaType  string   `json:"type"`
	Path    string   `json:"path"`
	Disable bool     `json:"disable"`
	Aliases []string `json:"aliases"`
	Options map[string]string
}

MaSetting is a setting structure

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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