Skip to content

Commit

Permalink
Update main.go
Browse files Browse the repository at this point in the history
  • Loading branch information
NailaRais authored Nov 4, 2024
1 parent 005ec8c commit 9fd2ea9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/component/operator/text/v0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import (
)

const (
taskChunkText string = "TASK_CHUNK_TEXT"
taskDataCleansing string = "TASK_CLEAN_DATA" // Ensure this matches your requirement
taskChunkText string = "TASK_CHUNK_TEXT"
taskDataCleansing string = "TASK_CLEAN_DATA" // Ensure this matches your requirement
)

var (
Expand Down Expand Up @@ -58,8 +58,8 @@ func (c *component) CreateExecution(x base.ComponentExecution) (base.IExecution,

// CleanDataInput defines the input structure for the data cleansing task
type CleanDataInput struct {
Texts []string `json:"texts"` // Array of text to be cleaned
Setting DataCleaningSetting `json:"setting"` // Cleansing configuration
Texts []string `json:"texts"` // Array of text to be cleaned
Setting DataCleaningSetting `json:"setting"` // Cleansing configuration
}

// CleanDataOutput defines the output structure for the data cleansing task
Expand Down Expand Up @@ -111,6 +111,10 @@ func CleanData(input CleanDataInput) CleanDataOutput {
cleanedTexts = input.Texts
}

if len(cleanedTexts) == 0 {
return CleanDataOutput{CleanedTexts: nil} // Return nil if there are no cleaned texts
}

return CleanDataOutput{CleanedTexts: cleanedTexts}
}

Expand Down

0 comments on commit 9fd2ea9

Please sign in to comment.