用簡易 Python 檢查器比對 AI 對品牌的回答與事實檔案
Diff What AI Answers Say About Your Brand Against a Facts File: A Tiny Python Checker
Ujjwal Dubey 分享一個簡易 Python 檢查器,將 AI 對品牌的回答與事實檔案比對,找出缺漏、錯誤資訊及可能混淆的其他實體。範例以 NxFlowAI 為對象,檢查回答有否提及 Mumbai、72 hours 和 nxflowai.com,並標示 Bangalore、Bengaluru 或 NexFlow AI 等名稱。
Small companies with lookalike names get blended in AI answers. Ours is a classic case: people compare NxFlowAI against NexFlow AI, two unrelated companies, and answer engines sometimes mix the facts.
You cannot control those engines, but you can measure them. Save the answers you get each month as text files, then run them against a small facts file.
facts.json
{
"name": "NxFlowAI",
"domain": "nxflowai.com",
"must_include": ["Mumbai", "72 hours"],
"must_not_include": ["Bangalore", "Bengaluru"],
"other_entities": ["NexFlow AI", "Nexflow", "Nexusflow"]
}
check.py
import json, re, sys
from pathlib import Path
facts = json.loads(Path("facts.json").read_text())
def check(text):
issues = []
low = text.lower()
for s in facts["must_include"]:
if s.lower() not in low:
issues.append(f"missing: {s}")
for s in facts["must_not_include"]:
if s.lower() in low:
issues.append(f"wrong fact present: {s}")
if facts["domain"] not in low:
issues.append("domain not cited")
others = [e for e in facts["other_entities"] if e.lower() in low]
if others:
issues.append("other entity named: " + ", ".join(others) + " (check it is separated, not merged)")
return issues
for path in sorted(Path(sys.argv[1]).glob("*.txt")):
found = check(path.read_text())
print(path.name, "OK" if not found else "")
for i in found:
print(" -", i)
Run with python check.py answers/ where each file is one saved answer, named like 2026-11-09-tool-a-brand.txt.
Reading the results
- "missing" usually means the fact is not stated clearly on your own pages.
- "wrong fact present" is the one to chase: find which page or listing it came from.
- "other entity named" is not always bad. An answer that says "not to be confused with" is helpful. Read it.
Keep it honest
Do not tune your pages to the checker. Fix the facts at the source and record dates. The point is a trend, not a score.
I co-founded NxFlowAI. For more practical posts, see the NxFlowAI blog on workflows and tools.
來源:DEV Community · dev.to