File: chunk_fuzz.go

package info (click to toggle)
golang-github-jdkato-prose 1.2.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 12,904 kB
  • sloc: python: 115; makefile: 52; sh: 41
file content (28 lines) | stat: -rw-r--r-- 425 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// +build gofuzz

package chunk

import (
	"github.com/jdkato/prose/tag"
	"github.com/jdkato/prose/tokenize"
)

func Fuzz(data []byte) int {
	words := tokenize.TextToWords(string(data))
	if len(words) == 0 {
		return 0
	}

	tagger := tag.NewPerceptronTagger()
	tagged := tagger.Tag(words)
	if len(tagged) == 0 {
		return 0
	}

	chunks := Chunk(tagged, TreebankNamedEntities)
	if len(chunks) == 0 {
		return 0
	}

	return 1
}