cabocha

package module
v0.0.0-...-564bb0f Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2022 License: AGPL-3.0 Imports: 5 Imported by: 0

README

go-cabocha

cabocha binding for golang.

Installation

brew install cabocha #for mac osx
sudo apt-get install cabocha #for debian/ubuntu
go install "github.com/ledyba/go-cabocha"

Usage

import (
	cabocha "github.com/ledyba/go-cabocha"
	"log"
)

func main() {
	cabo = cabocha.MakeCabocha()
	sentence, err := cabocha.Parse("あなたとJava")
	if err != nil {
		log.Error(err)
	}
	for _,chunk := range sentence.Chunks {
		log.Printf("Id: %d",chunk.Id)
		log.Printf("Link: %d",chunk.Link)
		log.Printf("Head: %d",chunk.Head)
		log.Printf("Func: %d",chunk.Func)
		// and so on...
		for _,token := range chunk.Tokens {
			log.Printf("    Id: %d",token.Id)
			log.Printf("    Features: %s",chunk.Features)
			log.Printf("    %s",chunk.Body)
		}
	}
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cabocha

type Cabocha struct {
	// contains filtered or unexported fields
}

func MakeCabocha

func MakeCabocha() *Cabocha

func MakeCabochaWithPath

func MakeCabochaWithPath(path string) *Cabocha

func (*Cabocha) Parse

func (cabo *Cabocha) Parse(sentence string) (*Sentence, error)

type Chunk

type Chunk struct {
	XMLName xml.Name `xml:"chunk"`
	Tokens  []Token  `xml:"tok"`
	ID      int      `xml:"id,attr"`
	Link    int      `xml:"link,attr"`
	Rel     string   `xml:"rel,attr"`
	Score   float32  `xml:"score,attr"`
	Head    int      `xml:"head,attr"`
	Func    int      `xml:"func,attr"`
}

func (*Chunk) ToString

func (chunk *Chunk) ToString() string

type Sentence

type Sentence struct {
	Text    string   `xml:"-"`
	XMLName xml.Name `xml:"sentence"`
	Chunks  []Chunk  `xml:"chunk"`
	Tokens  []*Token `xml:"-"`
}

func (*Sentence) Chunk

func (self *Sentence) Chunk(id int) *Chunk

func (*Sentence) ToString

func (sentence *Sentence) ToString() string

func (*Sentence) Token

func (self *Sentence) Token(id int) *Token

type Token

type Token struct {
	XMLName  xml.Name `xml:"tok"`
	ID       int      `xml:"id,attr"`
	Feature  string   `xml:"feature,attr"`
	Features []string `xml:"-"`
	Body     string   `xml:",chardata"`
}

func (*Token) Base

func (tok *Token) Base() string

func (*Token) Contains

func (tok *Token) Contains(feature string) bool

func (*Token) Pron

func (tok *Token) Pron() string

func (*Token) Reading

func (tok *Token) Reading() string

func (*Token) Surface

func (tok *Token) Surface() string

Jump to

Keyboard shortcuts

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