public detectLanguageBatch ( array $strings, array $options = [] ) : array | ||
$strings | array | |
$options | array | [optional] { Configuration Options. @type string $format Indicates whether the string is either plain-text or HTML. Acceptable values are `html` or `text`. **Defaults to** `"html"`. } |
리턴 | array | A set of results. Each result includes a `languageCode` key containing the detected ISO 639-1 language code, an `input` key containing the original string, and in most cases a `confidence` key containing a value between 0 - 1 signifying the confidence of the result. |
public function detectLanguageBatch(array $strings, array $options = [])
{
$response = $this->connection->listDetections($options + ['q' => $strings, 'key' => $this->key]);
$detections = [];
foreach ($response['data']['detections'] as $key => $detection) {
$detection = $detection[0];
$detections[] = array_filter(['languageCode' => $detection['language'], 'input' => $strings[$key], 'confidence' => isset($detection['confidence']) ? $detection['confidence'] : null]);
}
return $detections;
}