الفحص

استخدم واجهة الفحص في قُبة لكشف الكيانات الحساسة في النص، مع درجة الثقة في كل منها.

نظرة عامة

تكشف واجهة الفحص (Scan API) الكيانات الحساسة في النص، وتُعيد موضع كل كيان ونوعه ودرجة الثقة فيه. استخدمها لتعرف ما في النص من معلومات شخصية أو سرية أو خاضعة لأنظمة تنظيمية، قبل أن تقرر كيف تتعامل معها.

const response = await api.scanText({
  text: "Patient John Smith (ID: 12345) was treated at Dubai Hospital",
  language: "en",
  entities: ["person", "id", "location"],
  confidence_threshold: 0.5,
})
response = scan_text.sync(
    client=client,
    body=models.ScanRequestBody(
        text="Patient John Smith (ID: 12345) was treated at Dubai Hospital",
        language="en",
        entities=["person", "id", "location"],
        confidence_threshold=0.5,
    ),
)

المعاملات

المعاملالنوعالقيمة الافتراضيةالوصف
textstringالنص المراد فحصه
languagestring"en"رمز اللغة
entitiesstring[]["id","name","email","location"]أنواع الكيانات المطلوب كشفها
confidence_thresholdnumberأدنى درجة ثقة مقبولة (0.0–1.0)

نتائج الفحص

تمثّل نتيجة الفحص كياناً مكتشَفاً، أي كياناً عثر عليه النموذج في النص. لا تُطبَّق عليها أي قاعدة، فهي تخبرك فقط بما وُجد وأين وُجد. وبهذا تختلف عن نتيجة تطبيق القاعدة التي تسجّل ما تغيّر في النص بعد تنفيذ القاعدة.

تفيدك نتائج الفحص في:

  • مراجعة البيانات الحساسة الموجودة في النص قبل معالجته
  • اختيار القواعد التي ستطبّقها في طلب إخفاء الهوية التالي

الاستجابة

يمثّل كل عنصر في المصفوفة response.results كياناً مكتشَفاً واحداً:

{
  start: 8,          // character offset (inclusive)
  end: 18,           // character offset (exclusive)
  score: 0.92,       // AI confidence (0.0–1.0)
  entity_type: "person"
}
الحقلالنوعالوصف
startnumberموضع أول حرف من الكيان في النص المُدخل
endnumberموضع نهاية الكيان (غير مشمول)
scorenumberدرجة الثقة التي يمنحها نموذج الذكاء الاصطناعي
entity_typestringنوع الكيان المكتشَف (مثل "person")

استخدم text.slice(result.start, result.end) لاستخراج المقطع المطابق من النص.

مثال

const text = "Contact John Doe at john.doe@example.com"

const response = await api.scanText({
  text,
  entities: ["person", "email"],
})

for (const result of response.results) {
  const matched = text.slice(result.start, result.end)
  console.log(`${result.entity_type}: "${matched}" (score: ${result.score})`)
}
// person: "John Doe" (score: 0.94)
// email:  "john.doe@example.com" (score: 0.99)
text = "Contact John Doe at john.doe@example.com"

response = scan_text.sync(
    client=client,
    body=models.ScanRequestBody(text=text, entities=["person", "email"]),
)

for result in response.results:
    matched = text[result.start : result.end]
    print(f'{result.entity_type}: "{matched}" (score: {result.score})')
# person: "John Doe" (score: 0.94)
# email:  "john.doe@example.com" (score: 0.99)
© 2026 قُبة