Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
ccampo133 committed Mar 27, 2024
1 parent b5051e8 commit ae6a153
Show file tree
Hide file tree
Showing 5 changed files with 544 additions and 396 deletions.
17 changes: 7 additions & 10 deletions classification/classification.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@ type ClassifiedTable struct {

// Result represents the classification of a data attribute.
type Result struct {
Table *ClassifiedTable `json:"table"`
AttributeName string `json:"attributeName"`
Classifications []*Label `json:"classifications"`
AttributeName string `json:"attributeName"`
Classifications []*Label `json:"classifications"`
}

// Classifier implementations know how to turn a row of data into a sequence of
Expand All @@ -41,11 +40,7 @@ type Classifier interface {
// If however, there is no assigned classification, we will skip it in the
// results. A zero length return value is normal if none of the attributes
// matched the classification requirements.
Classify(
ctx context.Context,
table *ClassifiedTable,
attrs map[string]any,
) ([]Result, error)
Classify(ctx context.Context, attrs map[string]any) (map[string][]Label, error)
}

// ClassifySamples uses the provided classifiers to classify the sample data
Expand All @@ -68,14 +63,16 @@ func ClassifySamples(
Schema: sample.Metadata.Schema,
Table: sample.Metadata.Table,
}
// TODO: use the table -ccampo 2024-03-27
_ = table
// Classify each sampled row
for _, sampleResult := range sample.Results {
for _, classifier := range classifiers {
res, err := classifier.Classify(ctx, &table, sampleResult)
_, err := classifier.Classify(ctx, sampleResult)
if err != nil {
return nil, fmt.Errorf("error classifying sample: %w", err)
}
classifications = append(classifications, res...)
//classifications = append(classifications, res...)
}
}
}
Expand Down
Loading

0 comments on commit ae6a153

Please sign in to comment.