2019-03-24 17:55:05 +00:00
|
|
|
// +build flex
|
2019-03-24 01:06:19 +00:00
|
|
|
|
2019-03-24 17:55:05 +00:00
|
|
|
package tokenizer
|
2019-03-24 01:06:19 +00:00
|
|
|
|
2019-03-24 17:55:05 +00:00
|
|
|
import "gopkg.in/src-d/enry.v1/internal/tokenizer/flex"
|
2019-03-24 01:06:19 +00:00
|
|
|
|
2019-04-14 20:15:18 +00:00
|
|
|
// Tokenize returns lexical tokens from content. The tokens returned match what
|
|
|
|
// the Linguist library returns. At most the first ByteLimit bytes of content are tokenized.
|
|
|
|
// Splitting at a byte offset means it might partition a last multibyte unicode character
|
|
|
|
// in the middle of a token (but it should not affect results).
|
2019-03-24 17:55:05 +00:00
|
|
|
func Tokenize(content []byte) []string {
|
2019-04-14 20:15:18 +00:00
|
|
|
if len(content) > ByteLimit {
|
|
|
|
content = content[:ByteLimit]
|
2019-03-24 01:06:19 +00:00
|
|
|
}
|
|
|
|
|
2019-03-24 17:55:05 +00:00
|
|
|
return flex.TokenizeFlex(content)
|
2019-03-24 01:06:19 +00:00
|
|
|
}
|