forked from CodeWithKyrian/transformers-php
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathByteLevelPostProcessor.php
More file actions
37 lines (30 loc) · 1014 Bytes
/
ByteLevelPostProcessor.php
File metadata and controls
37 lines (30 loc) · 1014 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
declare(strict_types=1);
namespace Codewithkyrian\Transformers\PostProcessors;
/**
* A PostProcessor that returns the given tokens as is.
*/
class ByteLevelPostProcessor extends PostProcessor
{
/**
* @param array $config
*/
public function __construct(array $config)
{
parent::__construct($config);
}
/**
* Post process the given tokens.
* @param string[] $tokens The input tokens.
* @param string[]|null $tokenPair The input tokens for the second sequence in a pair.
* @param bool $addSpecialTokens Whether to add the special tokens associated with the corresponding model.
* @return PostProcessedOutput
*/
public function postProcess(array $tokens, ?array $tokenPair = null, bool $addSpecialTokens = true): PostProcessedOutput
{
if ($tokenPair !== null) {
$tokens = array_merge($tokens, $tokenPair);
}
return new PostProcessedOutput($tokens, array_fill(0, count($tokens), 0));
}
}