client

package
v0.4.5 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2023 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesUnmarshal

func BytesUnmarshal(data []byte, msg protoreflect.ProtoMessage) error

BytesUnmarshal unmarshals coreNLP protobuf data

Types

type Cmd

type Cmd struct {
	// a slice of annotators. e.g. []string{"tokenize","ssplit","pos","depparse"}
	Annotators []string

	// Classpath to the Java.
	ClassPath string

	// Class to run for annotators
	Class string

	// extra arguments for the Java command
	Args []string
	// contains filtered or unexported fields
}

Cmd runs Stanford CoreNLP under command line. The original Java-based CoreNLP package must be downloaded and installed properly.

see https://stanfordnlp.github.io/CoreNLP/index.html

func NewCmd

func NewCmd(annotators []string, args ...string) *Cmd

NewCmd creates an instance of Cmd.

annotators: the list of annotators;

args[0], optional: the Java Classpath;

args[1], optional: the Java class;

args[2], optional: the Java command;

args[3:], optional: other arguments.

For example, if the CoreNLP is downloaded and unzipped to /home/user/standford, you can create instance: NewCmd([]string{"tokenize","ssplit","pos"}, "/home/user/standford/*")

see https://stanfordnlp.github.io/CoreNLP/cmdline.html

func (*Cmd) Run

func (self *Cmd) Run(ctx context.Context, input string, msg protoreflect.ProtoMessage) error

Runs on the input file, and gets the NLP data in msg.

Note that Document{} is the root component in the auto-generated NLP protobuf package.

func (*Cmd) RunText

func (self *Cmd) RunText(ctx context.Context, text []byte, msg protoreflect.ProtoMessage) error

RunText runs on the text string, and gets the NLP data in msg

type HttpClient

type HttpClient struct {
	// a slice of annotators. e.g. []string{"tokenize","ssplit","pos","depparse"}
	Annotators []string

	// server's URL
	URL string
}

HttpClient runs Stanford CoreNLP as a HTTP client The CoreNLP server must be actively running.

see https://stanfordnlp.github.io/CoreNLP/index.html

func NewHttpClient

func NewHttpClient(annotators []string, args ...string) *HttpClient

NewHttpClient creates an instance of HttpClient

annotators: the list of annotators;

args[0], optional: the server address, default to http://127.0.0.1:9000;

func (*HttpClient) Run

func (self *HttpClient) Run(ctx context.Context, input string, msg protoreflect.ProtoMessage) error

Runs on the input file, and gets the NLP data in msg

Note that Document{} is the root component in the auto-generated NLP protobuf package.

func (*HttpClient) RunText

func (self *HttpClient) RunText(ctx context.Context, text []byte, msg protoreflect.ProtoMessage) error

RunText runs on the text string, and gets the NLP data in msg

Jump to

Keyboard shortcuts

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