PHP code example of bahasaai / klasifikasi-php

1. Go to this page and download the library: Download bahasaai/klasifikasi-php library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bahasaai / klasifikasi-php example snippets



use klasifikasi\Klasifikasi;

$klasifikasiInstance = Klasifikasi::build([
    [
        'clientId' => 'client-id-1',
        'clientSecret' => 'client-id-2'
    ]
]);

$klasifikasiInstance = Klasifikasi::build([
    [
        'clientId' => 'client-id-1',
        'clientSecret' => 'client-secret-1'
    ],
    [
        'clientId' => 'client-id-2',
        'clientSecret' => 'client-secret-2'
    ]
]);

foreach ($klasifikasiInstance->getModels() as $publicId => $model) {
  echo $publicId;
}

$result = $publicId->classify('publicId', 'query');
/**
 * $result example = array[
 *  'result' => array[
 *    [
 *      'label' => 'tag 1',
 *      'score' => 0.53
 *    ],
 *    [
 *      'label' => 'tag 2',
 *      'score' => 0.23
 *    ]
 *  ]
 * ]
*/

$startedAtString = '10 December 2020';

$endedAtString = '16 December 2020';

$logs = $instance->logs('publicId', [
    'startedAt' => new DateTime($startedAtString),
    'endedAt' => new DateTime($endedAtString),
    'take' => 10
    'skip' => 1
]);
/**
 * $logs example = array[
 *  'histories' => array[
 *    [
 *      'id' => 1,
 *      'createdAt' => '2020-12-15T11:13:12+07:00',
 *      'query' => 'query',
 *      'modelResult' => array[
 *        [
 *          'label' => 'tag 1',
 *          'score' => 0.53
 *        ],
 *        [
 *          'label' => 'tag 2',
 *          'score' => 0.23
 *        ]
 *      ]
 *    ],
 *    ...
 *  ],
 *  'length' => int
 * ]
*/

bash
composer