PerspectiveAnalyzeCommentResponse
Response returned by Respectify's public Perspective-compatible analyse endpoint.
- Python
- PHP
- JSON
from respectify.schemas import PerspectiveAnalyzeCommentAttributeScore, PerspectiveAnalyzeCommentResponse
use Respectify\Schemas\PerspectiveAnalyzeCommentAttributeScore;
use Respectify\Schemas\PerspectiveAnalyzeCommentResponse;
Types are returned as JSON objects in API responses.
Fields
attributeScores
Map of requested Perspective attribute names, such as TOXICITY or INSULT, to their score objects. Each value contains a summaryScore and, when requested, optional spanScores.
- Python
- PHP
- JSON
result.attributeScores: Dict[str, PerspectiveAnalyzeCommentAttributeScore]
$result->attributeScores: array<string, PerspectiveAnalyzeCommentAttributeScore>
"attributeScores": {
"ATTRIBUTE_NAME": {
"summaryScore": PerspectiveScore,
"spanScores": [PerspectiveAnalyzeCommentSpanScore, ...]
}
}
Each key is a requested attribute name such as TOXICITY. Each value is a PerspectiveAnalyzeCommentAttributeScore object.
languages
Requested or effective language context for this response, as language codes such as en, es, or fr.
- Python
- PHP
- JSON
result.languages: List[str]
$result->languages: str[]
"languages": ["...", "..."]
detectedLanguages
Present only if Respectify actually detected languages, as language codes such as en, es, or fr.
- Python
- PHP
- JSON
result.detectedLanguages: Optional[List[str]]
$result->detectedLanguages: ?array<int, str>
"detectedLanguages": ["...", "..."]
clientToken
Caller-provided correlation token, echoed back unchanged when supplied. Use this if you want to match the response to your own request ID.
- Python
- PHP
- JSON
result.clientToken: Optional[str]
$result->clientToken: ?string
"clientToken": "string" // or null
Sub-types
PerspectiveAnalyzeCommentAttributeScore
Google-style attribute score entry returned by analyzeComment.
- Python
- PHP
- JSON
| Field | Type | Description |
|---|---|---|
summaryScore | PerspectiveScore | Overall score for the attribute. This is the main score most integrations use for thresholds and moderation decisions. |
spanScores | Optional[List[PerspectiveAnalyzeCommentSpanScore]] | Optional scores for specific spans of text that contributed to the attribute. Returned only when span annotations were requested. |
| Field | Type | Description |
|---|---|---|
summaryScore | PerspectiveScore | Overall score for the attribute. This is the main score most integrations use for thresholds and moderation decisions. |
spanScores | ?array<int, PerspectiveAnalyzeCommentSpanScore> | Optional scores for specific spans of text that contributed to the attribute. Returned only when span annotations were requested. |
{
"summaryScore": {},
"spanScores": []
}
PerspectiveAnalyzeCommentSpanScore
Google-style span score for a specific part of the comment.
- Python
- PHP
- JSON
| Field | Type | Description |
|---|---|---|
begin | int | Start offset for the span in UTF-16 code units |
end | int | End offset for the span in UTF-16 code units |
score | PerspectiveScore | Score for this specific span |
| Field | Type | Description |
|---|---|---|
begin | int | Start offset for the span in UTF-16 code units |
end | int | End offset for the span in UTF-16 code units |
score | PerspectiveScore | Score for this specific span |
{
"begin": 1,
"end": 1,
"score": {}
}
PerspectiveScore
Google-style score object used in Perspective compatibility responses.
- Python
- PHP
- JSON
| Field | Type | Description |
|---|---|---|
value | float # 0.0-1.0 | Probability-style score between 0.0 and 1.0. Higher numbers mean more of the requested attribute. |
type | str | Score type. Respectify currently returns PROBABILITY, meaning the value is a 0 to 1 probability-style score. |
| Field | Type | Description |
|---|---|---|
value | float | Probability-style score between 0.0 and 1.0. Higher numbers mean more of the requested attribute. |
type | string | Score type. Respectify currently returns PROBABILITY, meaning the value is a 0 to 1 probability-style score. |
{
"value": 0.5,
"type": "string"
}