andriichuk/bing-spell-check-api-client

There is no license information available for the latest version (v0.0.1) of this package.

Bing Spell Check API Client

v0.0.1 2020-02-22 20:34 UTC

This package is auto-updated.

Last update: 2020-06-23 11:15:28 UTC


README

Installation

Install composer package:

composer install andriichuk/bing-spell-check-api-client

Usage

SpellCheck API

<?php

declare(strict_types=1);

require_once 'vendor/autoload.php';

use BingSpellCheck\BingSpellCheck;
use BingSpellCheck\Rest\SpellCheck\MessageBuilder;

$client = BingSpellCheck::create('576b4f45dcc54641927b607c42550bf3');

$messageBuilder = new MessageBuilder('Hllo wordl');
$messageBuilder->setMkt('en-us');
$messageBuilder->setMode('proof');

$response = $client->spellcheck()->getSuggestions($messageBuilder);

var_dump(
    $response->getFlaggedTokens()
);
Response

object(BingSpellCheck\Response\SpellCheckResponse)#41 (2) {
  ["type":"BingSpellCheck\Response\SpellCheckResponse":private]=>
  string(10) "SpellCheck"
  ["flaggedTokens":"BingSpellCheck\Response\SpellCheckResponse":private]=>
  array(2) {
    [0]=>
    object(BingSpellCheck\Response\FlaggedToken)#51 (4) {
      ["offset":"BingSpellCheck\Response\FlaggedToken":private]=>
      int(0)
      ["token":"BingSpellCheck\Response\FlaggedToken":private]=>
      string(4) "Hllo"
      ["type":"BingSpellCheck\Response\FlaggedToken":private]=>
      string(12) "UnknownToken"
      ["suggestions":"BingSpellCheck\Response\FlaggedToken":private]=>
      array(1) {
        [0]=>
        object(BingSpellCheck\Response\TokenSuggestion)#24 (2) {
          ["score":"BingSpellCheck\Response\TokenSuggestion":private]=>
          float(0.87564705034249)
          ["suggestion":"BingSpellCheck\Response\TokenSuggestion":private]=>
          string(5) "Hello"
        }
      }
    }
    [1]=>
    object(BingSpellCheck\Response\FlaggedToken)#25 (4) {
      ["offset":"BingSpellCheck\Response\FlaggedToken":private]=>
      int(5)
      ["token":"BingSpellCheck\Response\FlaggedToken":private]=>
      string(5) "wordl"
      ["type":"BingSpellCheck\Response\FlaggedToken":private]=>
      string(12) "UnknownToken"
      ["suggestions":"BingSpellCheck\Response\FlaggedToken":private]=>
      array(1) {
        [0]=>
        object(BingSpellCheck\Response\TokenSuggestion)#35 (2) {
          ["score":"BingSpellCheck\Response\TokenSuggestion":private]=>
          float(0.87564705034249)
          ["suggestion":"BingSpellCheck\Response\TokenSuggestion":private]=>
          string(5) "world"
        }
      }
    }
  }
}