Documentation
¶
Overview ¶
Classifier attempts to classify documents by topic.
Index ¶
Constants ¶
View Source
const ( NO_UNIT = iota // metric METERS INCHES FEET MILES TIME )
View Source
const ( NONE = iota LINK QUANTITY DATE ORG CARDINAL MONEY EVENT )
Variables ¶
View Source
var ( //go:embed data/cardinality.txt CARDINALITY_DICT_EMBED string CARDINALITY_DICT = LoadDictionary(CARDINALITY_DICT_EMBED) )
View Source
var (
ErrNoExtract = errors.New("couldn't determine meaning")
)
View Source
var NUM_REGEXP = regexp.MustCompile(`\d+`)
Matches any sequence of one or more numbers
View Source
var SINGLE_NUMBER_REGEXP = regexp.MustCompile(`\d`)
Matches a single number
View Source
var UNIT_EXTRACT_REGEXP = regexp.MustCompile(`\d+\s?[A-Z..a-z]+`)
Matches one or more numbers followed by optional whitespace and a sequence of one or more letters, used for determining whether a string may be a quantity or not.
View Source
var UNIT_TYPE_REGEXP = regexp.MustCompile(`[a-zA-Z]+`)
Matches one or more letters, used as a filter for determining the unit
View Source
var Units = [][]string{
NO_UNIT: {"none"},
METERS: {"meters", "m"},
INCHES: {"inches", "in"},
FEET: {"feet", "ft", "foot"},
MILES: {"mile", "mi"},
TIME: {"minute", "second", "hour", "day"},
}
Recognized units.
Functions ¶
func LoadDictionary ¶
Loads a dictionary from an embeded newline-delimited dictionary file. The dictionary words are placed in a trie.
Types ¶
type Result ¶
type Result struct {
// type of result
ResultType ResultType `json:"type"`
// title/label of the unit, as in with graphs
// e.g. "Number of Queries Per Second"
Label string `json:"label"`
// Custom data
Data dataType `json:"data"`
// value
Value string `json:"value"`
Start, End uint
}
type ResultType ¶
type ResultType int
func (ResultType) String ¶
func (r ResultType) String() string
Click to show internal directories.
Click to hide internal directories.