prose: github.com/jdkato/prose/chunk Index | Examples | Files

package chunk

import "github.com/jdkato/prose/chunk"

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

Code:

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

Package Files

chunk.go

Variables

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").

func Chunk Uses

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 Uses

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

Locate finds the chunks of interest according to the regexp.

Package chunk imports 2 packages (graph) and is imported by 2 packages. Updated 2017-09-13. Refresh now. Tools for package owners.