jk

package module
v0.0.0-...-549d542 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2021 License: Apache-2.0 Imports: 12 Imported by: 1

README

go-jk

CircleCI codecov.io Report card GoDoc Apache License

What's this

  • A go library of a Japanese morphological analyzer JUMAN and JUMAN++, and Japanese Dependency and Case Structure Analyzer KNP

INSTALL

go get github.com/shirayu/go-jk

Acknowledgement

I developed this program as a part of the research project "Establishment of Knowledge-Intensive Structural Natural Language Processing and Construction of Knowledge Infrastructure" in Kyoto University supported by CREST, JST.

Developers

  • Yuta Hayashibe

Licence

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgMap

type ArgMap map[string]Arguments

ArgMap is a map from string to Arguments

type Argument

type Argument struct {
	Sid string `json:"sid"`
	Tid int    `json:"tid"`
	Rep string `json:"rep"`
}

Argument represent a single argument

type Arguments

type Arguments []Argument

Arguments is a slice of Argument

type Client

type Client interface {
	RawParse(query string) (string, error)
	Parse(query string) (*Sentence, error)
}

Client parses the given plain texts

type CommandClient

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

CommandClient execute the given command

func NewCommandClient

func NewCommandClient(command string, options ...string) (*CommandClient, error)

NewCommandClient creates a new CommandClient

func (*CommandClient) RawParse

func (cmdcl *CommandClient) RawParse(query string) (string, error)

RawParse returns a single raw result which ends with "EOS" for the given sentence

type DependencyInfo

type DependencyInfo struct {
	To       int
	DepType  rune
	Features Features
	Pas      *Pas
}

DependencyInfo handles dependency information of bunsetsu or basic phrases

func NewDependencyInfo

func NewDependencyInfo(line string) (*DependencyInfo, error)

NewDependencyInfo creates a new DependencyInfo with the given line

func (*DependencyInfo) GetPredRep

func (depi *DependencyInfo) GetPredRep() string

GetPredRep returns the "rep" for the DependencyInfo

type DependencyInfos

type DependencyInfos []*DependencyInfo

DependencyInfos is a slice of DependencyInfo

type Document

type Document struct {
	Sentences Sentences
}

Document is a set of sentences

func NewDocument

func NewDocument(scanner *bufio.Scanner) (*Document, error)

NewDocument creates Document

func (*Document) GetSentenceIndex

func (doc *Document) GetSentenceIndex(sid string) int

GetSentenceIndex returns the index by SID

type Features

type Features map[string]string

Features is a map of features

type Juman

type Juman struct {
	*CommandClient
}

Juman is a client to execute juman command or jumanpp command

func NewJuman

func NewJuman(path string, options ...string) (*Juman, error)

NewJuman creates a new Juman

func (*Juman) Parse

func (jmn *Juman) Parse(query string) (*Sentence, error)

Parse returns a Sentence to parse the given sentence

type JumanSocketClient

type JumanSocketClient struct {
	*SocketClient
}

JumanSocketClient is a client to a communicete juman server

func NewJumanSocketClient

func NewJumanSocketClient(address string) (*JumanSocketClient, error)

NewJumanSocketClient creates a new JumanSocketClient

func (*JumanSocketClient) Parse

func (jsc *JumanSocketClient) Parse(query string) (*Sentence, error)

Parse returns a Sentence to parse the given sentence

type Knp

type Knp struct {
	*CommandClient
}

Knp is a client to execute knp command

func NewKnp

func NewKnp(path string, options ...string) (*Knp, error)

NewKnp creates a new Knp

func (*Knp) Parse

func (knp *Knp) Parse(query string) (*Sentence, error)

Parse returns a Sentence to parse the given sentence

type KnpSocketClient

type KnpSocketClient struct {
	*SocketClient
}

KnpSocketClient is a client to a communicete knp server

func NewKnpSocketClient

func NewKnpSocketClient(address string) (*KnpSocketClient, error)

NewKnpSocketClient creates a new KnpSocketClient

func (*KnpSocketClient) Parse

func (knpsc *KnpSocketClient) Parse(jumanLines string) (*Sentence, error)

Parse returns a Sentence to parse the given sentence

type Morpheme

type Morpheme struct {
	Doukeis       Morphemes
	Surface       string   //Midashi
	Pronunciation string   //Yomi
	RootForm      string   //Genkei
	Pos0          string   //Hinshi
	Pos0ID        int      //HinshiID
	Pos1          string   //Bunrui
	Pos1ID        int      //BunruiID
	CType         string   //Katsuyou1
	CTypeID       int      //Katsuyou1ID
	CForm         string   //Katsuyou2
	CFormID       int      //Katsuyou2ID
	Seminfo       string   //Seminfo
	Rep           string   //Rep
	Features      Features //Features by KNP
}

Morpheme is a morpheme

func NewMorpheme

func NewMorpheme(line string) (*Morpheme, error)

NewMorpheme returns a morpheme for the given line

type Morphemes

type Morphemes []*Morpheme

Morphemes is a slice of Morpheme

type Pas

type Pas struct {
	Cfid string
	Args ArgMap
}

Pas represents a predicate argument structure

func NewPas

func NewPas(line string, knpstyle bool) (*Pas, error)

NewPas returns a Pas

type Sentence

type Sentence struct {
	Morphemes
	ID           string
	Bunsetsus    DependencyInfos
	BasicPhrases DependencyInfos

	MorphemePositions         []int
	BasicPhrasePositions      []int
	BasicPhraseMorphemeIndexs []int
	// contains filtered or unexported fields
}

Sentence includes elements of a sentence

func NewSentence

func NewSentence(lines []string) (*Sentence, error)

NewSentence creats a sentence with the given text

func (*Sentence) GetMorphemes

func (sent *Sentence) GetMorphemes(bpIndex int) Morphemes

GetMorphemes returns morpheme of the sentence

func (*Sentence) Len

func (sent *Sentence) Len() int

Len returns the number of the morphemes

type Sentences

type Sentences []*Sentence

Sentences a slice of Sentence

type SocketClient

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

SocketClient communicates to a server with a socket

func NewSocketClient

func NewSocketClient(address string, option string) (*SocketClient, error)

NewSocketClient creats a SocketClient

func (*SocketClient) RawParse

func (scc *SocketClient) RawParse(query string) (string, error)

RawParse returns a single raw result which ends with "EOS" for the given sentence

Jump to

Keyboard shortcuts

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