Skip to content

Commit

Permalink
chore: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
attiks committed Jul 14, 2023
1 parent 9dce451 commit 0f737b1
Showing 1 changed file with 1 addition and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,31 +130,6 @@ public function trainJobs($field_name = '', $limit = 1000) {
fputcsv($fp, $fields);
}
fclose($fp);
return;
// Validation data.
$size = min(50, round(0.1 * $limit));
$content = $this->buildData($field, $limit + 1, $size);
$fp = fopen('/var/www/validation.csv', 'w');
fputcsv($fp, ['excerpt', 'target_classification']);
foreach ($content as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);

// Validation data.
$content = $this->buildData($field, $limit + $size + 1, $size);
$fp = fopen('/var/www/testing.csv', 'w');
fputcsv($fp, ['excerpt', 'target_classification']);
foreach ($content as $fields) {
fputcsv($fp, $fields);
}
fclose($fp);

return;
// $validation = $this->uploadFile('validation_' . $field, $content);

//$response = $this->trainFile($field_name, $training['id'], $validation['id']);
return $response['id'];
}

/**
Expand Down Expand Up @@ -339,20 +314,15 @@ protected function buildData($field, $offset, $limit) : array {
$prompt = $job->label() . "\n" . $this->cleanPrompt($job->body->value);
$tags = [];
foreach ($job->{$field}->referencedEntities() as $tag) {
// $tags[] = 'lvl1 -> lvl2 -> ' . $tag->label();
$tags[] = $tag->label();
}

// while (count($tags) < 3) {
// $tags[] = 'test ' . count($tags);
// }

$data[] = [
'label' => implode(' | ', $tags),
'text' => $prompt,
];
}
print_r(count($data) . "\n");

return $data;
}

Expand Down Expand Up @@ -433,7 +403,6 @@ protected function cleanPrompt($prompt) {
$prompt = Unicode::truncate(strip_tags(trim($prompt)), 3900, TRUE);
$prompt = str_replace(["\r\n", "\r", "\n", "\\r", "\\n", "\\r\\n"], " ", $prompt);
$prompt = preg_replace("/ +/", ' ', $prompt);
// $prompt= substr($prompt, 0, 5000);

return $prompt;
}
Expand Down

0 comments on commit 0f737b1

Please sign in to comment.