مشاركة عبر


ISmartTagExtension.Recognize أسلوب

البحث في نص في مستند عن العناصر التي تم التعرف عليها.

مساحة الاسم:  Microsoft.Office.Tools.Word
التجميع:  Microsoft.Office.Tools.Word (في Microsoft.Office.Tools.Word.dll)

بناء الجملة

'إقرار
Sub Recognize ( _
    text As String, _
    site As ISmartTagRecognizerSite, _
    tokenList As ISmartTagTokenList, _
    context As SmartTagRecognizeContext _
)
void Recognize(
    string text,
    ISmartTagRecognizerSite site,
    ISmartTagTokenList tokenList,
    SmartTagRecognizeContext context
)

المعلمات

  • text
    النوع: System.String
    نص إلى بحث عن العناصر التي تم التعرف عليها.
  • site
    النوع: Microsoft.Office.Interop.SmartTag.ISmartTagRecognizerSite
    الموقع نص في مستند أو مصنف.
  • tokenList
    النوع: Microsoft.Office.Interop.SmartTag.ISmartTagTokenList
    نص في بحث عن العناصر المعروفة، مقسمة في قائمة في kens.
  • context
    النوع: Microsoft.Office.Tools.Word.SmartTagRecognizeContext
    كائن يوفر نص من الفقرة هو إرسال المعرف وأسلوب يمكنك استدعاء للإشارة إلى أنه قد تم العثور على علامة ذكى.

ملاحظات

Th هو أسلوب هو استدعاؤها بواسطة Visual Studio Tools لوقت تشغيل Officeبحث عن نص لشروط تم التعرف عليها. قم بتطبيق هذا أسلوب إذا كنت ترغب في تضمين خوارزميات بحث الخاص بك تشغيل أدوات التعرف القياسية بالإضافة إلى ذلك.

أمثلة

يوضح مثال التعليمة البرمجية التالية كيف إلى تنفيذ Recognizeالأسلوب. يقارن هذا التطبيق لكل علامة ذكية المصطلح إلى محتويات الفقرة. لكل حد العلامات ذكى في الفقرة، يضيف خاصية علامات ذكية مخصصة التعليمة البرمجية ومن ثم يستخدم PersistTagالطريقة للتعرف على العلامات ذكى. يفترض هذا المثال أن قيامك بإضافة مرجع إلى من Microsoft.المكتب.Interop.SmartTag من علامة تبويب .NET من صندوق الحوار تمت الإضافة مرجع. Th هو المثال رمز هو جزءا من بقعة صغيرة مثال عن توفيرها ل ISmartTagExtensionالواجهة.

Private Sub Recognize(ByVal text As String,
    ByVal site As ISmartTagRecognizerSite,
    ByVal tokenList As ISmartTagTokenList,
    ByVal context As SmartTagRecognizeContext) Implements ISmartTagExtension.Recognize

    For Each term As String In smartTagDemo.Terms
        ' Search the text for the current smart tag term.
        Dim index As Integer = text.IndexOf(term, 0)

        While (index >= 0)
            ' Create a smart tag token and a property bag for the recognized term.
            Dim propertyBag As ISmartTagProperties = site.GetNewPropertyBag()

            ' Write a new property value.
            Dim key As String = "Key1"
            propertyBag.Write(key, DateTime.Now.ToString())

            ' Attach the smart tag to the term in the document
            context.PersistTag(index, term.Length, propertyBag)

            ' Increment the index and then find the next instance of the smart tag term.
            index += term.Length
            index = text.IndexOf(term, index)
        End While
    Next
End Sub
void ISmartTagExtension.Recognize(string text, ISmartTagRecognizerSite site, ISmartTagTokenList tokenList, 
    SmartTagRecognizeContext context)
{

    foreach (string term in smartTagDemo.Terms)
    {
        // Search the text for the current smart tag term.
        int index = text.IndexOf(term, 0);

        while (index >= 0)
        {
            // Create a smart tag token and a property bag for the recognized term.
            ISmartTagProperties propertyBag = site.GetNewPropertyBag();

            // Write a new property value.
            string key = "Key1";
            propertyBag.Write(key, DateTime.Now.ToString());

            // Attach the smart tag to the term in the document
            context.PersistTag(index, term.Length, propertyBag);

            // Increment the index and then find the next instance of the smart tag term.
            index += term.Length;
            index = text.IndexOf(term, index);
        }
    }
}

أمن NET Framework.

راجع أيضًَا

المرجع

ISmartTagExtension واجهة

ISmartTagExtension الأعضاء

Microsoft.Office.Tools.Word مساحة الاسم