November 2018
Beginner to intermediate
348 pages
8h 32m
English
Now, without much further ado, let's write some code to ingest the data. First, we need a data structure of a training example:
// Example is a tuple representing a classification exampletype Example struct { Document []string Class}
The reason for this is so that we can parse our files into a list of Example. The function is shown here:
func ingest(typ string) (examples []Example, err error) { switch typ { case "bare", "lemm", "lemm_stop", "stop": default: return nil, errors.Errorf("Expected only \"bare\", \"lemm\", \"lemm_stop\" or \"stop\"") } var errs errList start, end := 0, 11 for i := start; i < end; i++ { // hold 30% for crossval matches, err := filepath.Glob(fmt.Sprintf("data/lingspam_public/%s/part%d/*.txt", typ, ...Read now
Unlock full access