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

result = client.check_relevance(
"This comment discusses the article topic",
article_id
)

print(f"On topic: {result.on_topic.on_topic}")
print(f"Confidence: {result.on_topic.confidence:.2f}")
print(f"Reasoning: {result.on_topic.reasoning}")

# Banned topics info
print(f"Banned topics found: {result.banned_topics.banned_topics}")
print(f"Quantity on banned: {result.banned_topics.quantity_on_banned_topics:.2f}")

With Banned Topics

Specify topics that shouldn't be discussed:

result = client.check_relevance(
"Let me tell you about politics...",
article_id,
banned_topics=['politics', 'religion', 'controversial-subject']
)

if result.banned_topics.banned_topics:
print(f"Comment violates banned topics: {result.banned_topics.banned_topics}")