PHP code example of survos / claims-bundle

1. Go to this page and download the library: Download survos/claims-bundle 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/ */

    

survos / claims-bundle example snippets


use Survos\ClaimsBundle\Service\ClaimIngestor;
use Survos\ClaimsBundle\Service\RawClaim;
use Survos\DataContracts\Vocabulary\DcTerms;

$rawClaims = [
    new RawClaim(DcTerms::TITLE->value,       'Welcome to Ocean City', 0.9,
        basis: "Printed caption reads 'Welcome to Ocean City'."),
    new RawClaim(DcTerms::DESCRIPTION->value, 'Beach scene with boardwalk.', 0.8),
    new RawClaim(DcTerms::TYPE->value,        'postcard', 0.95),
    new RawClaim(DcTerms::SUBJECT->value,     'boardwalk', 0.9),
    new RawClaim(DcTerms::SUBJECT->value,     'seaside',   0.8),
    new RawClaim('ssai:has_text',             true,        1.0),
];

$run = $ingestor->record(
    scope:       'tenant:rhs',
    subjectType: 'image',
    subjectId:   $image->getId(),
    source:      '[email protected]',
    rawClaims:   $rawClaims,
);
$em->flush();

use Survos\ClaimsBundle\Service\ClaimAggregator;

$view = $aggregator->aggregate('image', $image->getId(), 'tenant:rhs');

// Scalar predicate — one winner:
$view['dcterms:title']
// → ['value' => 'Welcome to Ocean City', 'confidence' => 0.9,
//    'basis' => "Printed caption …", 'source' => '[email protected]']

// List predicate — dedup + union:
$view['dcterms:subject']
// → ['value' => ['boardwalk', 'seaside'], 'confidence' => 0.9,
//    'source' => 'aggregated', 'items' => [...]]