chunk

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2020 License: MIT Imports: 2 Imported by: 4

Documentation

Overview

Package chunk implements functions for finding useful chunks in text previously tagged from parts of speech.

Example
txt := "Go is a open source programming language created at Google."

words := tokenize.TextToWords(txt)
tagger := tag.NewPerceptronTagger()

fmt.Println(Chunk(tagger.Tag(words), TreebankNamedEntities))
Output:

[Go Google]

Index

Examples

Constants

This section is empty.

Variables

View Source
var TreebankNamedEntities = regexp.MustCompile(
	`((CD__)*(NNP.)+(CD__|NNP.)*)+` +
		`((IN__)*(CD__)*(NNP.)+(CD__|NNP.)*)*`)

TreebankNamedEntities matches proper names, excluding prior adjectives, possibly including numbers and a linkage by preposition or subordinating conjunctions (for example "Bank of England").

Functions

func Chunk

func Chunk(tagged []tag.Token, rx *regexp.Regexp) []string

Chunk returns a slice containing the chunks of interest according to the regexp.

This is a convenience wrapper around Locate, which should be used if you need access the to the in-text locations of each chunk.

func Locate

func Locate(tagged []tag.Token, rx *regexp.Regexp) [][]int

Locate finds the chunks of interest according to the regexp.

Types

This section is empty.

Jump to

Keyboard shortcuts

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