J'essaye d'implémenter le Bing Spell Check API v7. Ceci est ma fonction actuelle:L'implémentation de l'API Bing Spell Check v7 renvoie 0 flaggedTokens
# spell check
function bing_spell_check($q, $lang) {
$param = array();
$param['appName'] = PRO_NAME;
$param['text'] = $q;
$param['setLang'] = $lang;
$url = 'https://api.cognitive.microsoft.com/bing/v7.0/SpellCheck?'.http_build_query($param);
$process = curl_init();
curl_setopt($process, CURLOPT_URL, $url);
curl_setopt($process, CURLOPT_TIMEOUT, 10);
curl_setopt($process, CURLOPT_RETURNTRANSFER, true);
curl_setopt($process, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($process, CURLOPT_HTTPHEADER,
array(
'Accept: application/ld+json',
'Ocp-Apim-Subscription-Key: '.PRO_BING_KEY_SPELL
)
);
$response = curl_exec($process);
return $response;
}
Le problème est que cet exemple:
print_r(bing_spell_check('en', 'whts yur name?'));
Retours:
{
"@context":{
"@vocab":"http:\/\/bingapis.com\/v7\/schemas\/",
"s":"http:\/\/schema.org\/",
"@base":"https:\/\/api.cognitive.microsoft.com\/api\/v7\/"
},
"@type":"SpellCheck",
"flaggedTokens":[
]
}
Ce qui signifie qu'il n'a pas trouvé d'erreurs. J'ai couru la même épreuve dans Bing's test tool, et j'ai reçu cette structure à la place:
{
"_type": "SpellCheck",
"FlaggedTokens": [
{
"Offset": 0,
"Token": "whts",
"Type": "UnknownToken",
"Suggestions": [
{
"suggestion": "what's",
"Score": 0.909352914464075
},
{
"suggestion": "whats",
"Score": 0.810588859407343
},
{
"suggestion": "what is",
"Score": 0.680176771139565
}
]
},
{
"Offset": 5,
"Token": "yur",
"Type": "UnknownToken",
"Suggestions": [
{
"suggestion": "your",
"Score": 0.909352914464075
}
]
}
]
}
Am quelque chose que je manque. Des idées? Merci!
peut pas croire que je ne l'ai pas remarqué une telle erreur stupide. C'est probablement le résultat de la programmation à 3h hehe. Réponse acceptée instantanément. Merci! – andufo
@andufo Pas de problème! Je suis content d'avoir pu vous aider. –