Skip to main content

Relevance Checking

Verify that comments stay on-topic and don't violate banned topic rules.

What it checks:

  • On-topic detection: Is the comment relevant to the article?
  • Banned topics: Does it discuss topics you've prohibited?

Reference

See the Relevance Checking API Reference for method signatures and parameters.

Response: CommentRelevanceResult

By Example

Basic Usage

const result = await client.checkRelevance(
"This comment discusses the article topic",
articleId
);

console.log(`On topic: ${result.on_topic.on_topic}`);
console.log(`Confidence: ${result.on_topic.confidence.toFixed(2)}`);
console.log(`Reasoning: ${result.on_topic.reasoning}`);

// Banned topics info
console.log(`Banned topics found: ${result.banned_topics.banned_topics}`);
console.log(`Quantity on banned: ${result.banned_topics.quantity_on_banned_topics.toFixed(2)}`);

With Banned Topics

Specify topics that shouldn't be discussed:

const result = await client.checkRelevance(
"Let me tell you about politics...",
articleId,
["politics", "religion", "controversial-subject"]
);

if (result.banned_topics.banned_topics.length > 0) {
console.log(`Comment violates banned topics: ${result.banned_topics.banned_topics}`);
}