pos

package module
v0.0.0-...-4767fdc Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2017 License: MIT Imports: 8 Imported by: 0

README

Go-Stanford-NLP

License GoDoc GoReport Build Status

Go wrapper for Stanford NLP Part-Of-Speech Tagger (GPLv2)

More info: http://nlp.stanford.edu/software/tagger.shtml

Install

Install the package with:

go get github.com/kamildrazkiewicz/go-stanford-nlp

Import it with:

import "github.com/kamildrazkiewicz/go-stanford-nlp"

and use pos as the package name inside the code.

Example

func main() {
	var (
		tagger *pos.Tagger
		res    []*pos.Result
		err    error
	)

	if tagger, err = pos.NewTagger(
		"ext/english-left3words-distsim.tagger",    // path to model
		"ext/stanford-postagger.jar"); err != nil { // path to jar tagger file
		fmt.Print(err)
		return
	}
	if res, err = tagger.Tag("What is your name?"); err != nil {
		fmt.Print(err)
		return
	}
	for _, r := range res {
		fmt.Println(r.Word, r.TAG, r.Description())
	}

}

Output will be:

What WP Wh-pronoun
is VBZ Verb, 3rd person singular present
your PRP$ Possessive pronoun
name NN Noun, singular or mass
? .

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Descriptions = map[string]string{
	"CC":   "Coordinating conjunction",
	"CD":   "Cardinal number",
	"DT":   "Determiner",
	"EX":   "Existential there",
	"FW":   "Foreign word",
	"IN":   "Preposition or subordinating conjunction",
	"JJ":   "Adjective",
	"JJR":  "Adjective, comparative",
	"JJS":  "Adjective, superlative",
	"LS":   "List item marker",
	"MD":   "Modal",
	"NN":   "Noun, singular or mass",
	"NNS":  "Noun, plural",
	"NNP":  "Proper noun, singular",
	"NNPS": "Proper noun, plural",
	"PDT":  "Predeterminer",
	"POS":  "Possessive ending",
	"PRP":  "Personal pronoun",
	"PRP$": "Possessive pronoun",
	"RB":   "Adverb",
	"RBR":  "Adverb, comparative",
	"RBS":  "Adverb, superlative",
	"RP":   "Particle",
	"SYM":  "Symbol",
	"TO":   "to",
	"UH":   "Interjection",
	"VB":   "Verb, base form",
	"VBD":  "Verb, past tense",
	"VBG":  "Verb, gerund or present participle",
	"VBN":  "Verb, past participle",
	"VBP":  "Verb, non-3rd person singular present",
	"VBZ":  "Verb, 3rd person singular present",
	"WDT":  "Wh-determiner",
	"WP":   "Wh-pronoun",
	"WP$":  "Possessive wh-pronoun",
	"WRB":  "Wh-adverb",
}

Descriptions - word tags description https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html

Functions

This section is empty.

Types

type Result

type Result struct {
	Word string
	TAG  string
}

Result struct

func (*Result) Description

func (r *Result) Description() string

Description - returns tag description

type Tagger

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

Tagger struct

func NewTagger

func NewTagger(m, t string) (*Tagger, error)

NewTagger - returns Tagger pointer

func (*Tagger) SetEncoding

func (p *Tagger) SetEncoding(e string)

SetEncoding - set outupt encoding (default: utf8)

func (*Tagger) SetJavaOpts

func (p *Tagger) SetJavaOpts(opts []string)

SetJavaOpts - set java options (default: [mx300m])

func (*Tagger) SetJavaPath

func (p *Tagger) SetJavaPath(j string)

SetJavaPath - set path to java executable file

func (*Tagger) SetModel

func (p *Tagger) SetModel(m string) error

SetModel - set stanford pos tagger model

func (*Tagger) SetTagger

func (p *Tagger) SetTagger(t string) error

SetTagger - set stanford pos tagger jar file

func (*Tagger) Tag

func (p *Tagger) Tag(input string) ([]*Result, error)

Tag - use stanford pos tagger to tag input sentence

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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