Documentation ¶
Index ¶
- type Error
- type Lattice
- type MeCab
- func (m MeCab) Destroy()
- func (m MeCab) Error() error
- func (m MeCab) Parse(s string) (string, error)
- func (m MeCab) ParseLattice(lattice Lattice) error
- func (m MeCab) ParseToNode(s string) (Node, error)
- func (m MeCab) ParseToString(s string) (string, error)
- func (m MeCab) ParseToWordNodes(s string) ([]WordNode, error)
- type Model
- type Node
- func (node Node) Alpha() float32
- func (node Node) BNext() Node
- func (node Node) Beta() float32
- func (node Node) CharType() int
- func (node Node) Cost() int
- func (node Node) ENext() Node
- func (node Node) Feature() string
- func (node Node) ID() int
- func (node Node) IsBest() bool
- func (node Node) IsZero() bool
- func (node Node) LCAttr() int
- func (node Node) Length() int
- func (node Node) Next() Node
- func (node Node) Prev() Node
- func (node Node) Prob() float32
- func (node Node) RCAttr() int
- func (node Node) RLength() int
- func (node Node) Stat() NodeStat
- func (node Node) String() string
- func (node Node) Surface() string
- func (node Node) WCost() int
- type NodeStat
- type TokenizedWord
- type WordNode
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error is an error of MeCab.
type Lattice ¶
type Lattice struct {
// contains filtered or unexported fields
}
Lattice is a lattice.
func (Lattice) IsAvailable ¶
IsAvailable returns the lattice is available.
func (Lattice) SetSentence ¶
SetSentence set the sentence in the lattice.
type MeCab ¶
type MeCab struct {
// contains filtered or unexported fields
}
MeCab is a morphological parser.
func (MeCab) Parse ¶
Parse parses the string and returns the result as string
Example ¶
options := map[string]string{} if path := os.Getenv("MECABRC_PATH"); path != "" { options["rcfile"] = path } tagger, err := mecab.New(options) if err != nil { panic(err) } defer tagger.Destroy() result, err := tagger.Parse("こんにちは世界") if err != nil { panic(err) } fmt.Println(result)
Output: こんにちは 感動詞,*,*,*,*,*,こんにちは,コンニチハ,コンニチワ 世界 名詞,一般,*,*,*,*,世界,セカイ,セカイ EOS
func (MeCab) ParseLattice ¶
ParseLattice parses the lattice and returns the result as string.
Example ¶
options := map[string]string{} if path := os.Getenv("MECABRC_PATH"); path != "" { options["rcfile"] = path } tagger, err := mecab.New(options) if err != nil { panic(err) } defer tagger.Destroy() lattice, err := mecab.NewLattice() if err != nil { panic(err) } lattice.SetSentence("こんにちは世界") err = tagger.ParseLattice(lattice) if err != nil { panic(err) } fmt.Println(lattice.String())
Output: こんにちは 感動詞,*,*,*,*,*,こんにちは,コンニチハ,コンニチワ 世界 名詞,一般,*,*,*,*,世界,セカイ,セカイ EOS
func (MeCab) ParseToNode ¶
ParseToNode parses the string and returns the result as Node
Example ¶
options := map[string]string{} if path := os.Getenv("MECABRC_PATH"); path != "" { options["rcfile"] = path } tagger, err := mecab.New(options) if err != nil { panic(err) } defer tagger.Destroy() // XXX: avoid GC problem with MeCab 0.996 (see https://github.com/taku910/mecab/pull/24) tagger.Parse("") node, err := tagger.ParseToNode("こんにちは世界") if err != nil { panic(err) } for ; !node.IsZero(); node = node.Next() { fmt.Printf("%s\t%s\n", node.Surface(), node.Feature()) }
Output: BOS/EOS,*,*,*,*,*,*,*,* こんにちは 感動詞,*,*,*,*,*,こんにちは,コンニチハ,コンニチワ 世界 名詞,一般,*,*,*,*,世界,セカイ,セカイ BOS/EOS,*,*,*,*,*,*,*,*
func (MeCab) ParseToString ¶
ParseToString is alias of Parse
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model is a dictionary model of MeCab.
func (Model) NewLattice ¶
NewLattice returns a new lattice.
type Node ¶
type Node struct {
// contains filtered or unexported fields
}
Node is a node in a lattice.
type NodeStat ¶
type NodeStat int
NodeStat is status of a node.
const ( // NormalNode is status for normal node. NormalNode NodeStat = 0 // UnknownNode is status for unknown node. UnknownNode NodeStat = 1 // BOSNode is status for BOS(Begin Of Sentence) node. BOSNode NodeStat = 2 // EOSNode is status for EOS(End Of Sentence) node. EOSNode NodeStat = 3 // EONNode is status for EON(End Of Node) node. EONNode NodeStat = 4 )
type TokenizedWord ¶
Click to show internal directories.
Click to hide internal directories.