ISmartTagExtension.Recognize – metoda
Prohledá text rozpoznaný termínů v dokumentu.
Obor názvů: Microsoft.Office.Tools.Word
Sestavení: Microsoft.Office.Tools.Word (v Microsoft.Office.Tools.Word.dll)
Syntaxe
'Deklarace
Sub Recognize ( _
text As String, _
site As ISmartTagRecognizerSite, _
tokenList As ISmartTagTokenList, _
context As SmartTagRecognizeContext _
)
void Recognize(
string text,
ISmartTagRecognizerSite site,
ISmartTagTokenList tokenList,
SmartTagRecognizeContext context
)
Parametry
- text
Typ: System.String
Podmínky rozpoznán text vyhledat.
- site
Typ: Microsoft.Office.Interop.SmartTag.ISmartTagRecognizerSite
Umístění textu v dokumentu nebo sešitu.
- tokenList
Typ: Microsoft.Office.Interop.SmartTag.ISmartTagTokenList
Podmínky rozdělené seznam tokenů rozpoznán text vyhledat.
- context
Typ: Microsoft.Office.Tools.Word.SmartTagRecognizeContext
Označte, že byl nalezen inteligentní značky můžete volat objekt , který obsahuje text z odstavce odeslaný na metoda a nástroj pro rozpoznávání.
Poznámky
Tato metoda volá Visual Studio Tools for Office runtime Hledat text rozpoznaný podmínky. Pokud chcete zahrnout vlastní vyhledávací algoritmy spouštění kromě standardní rozpoznávání implementujte tuto metoda .
Příklady
Následující příklad kódu ukazuje, jak implementovat Recognize metody. Tato implementace porovná každý pojem inteligentní značku odstavce obsah. Pro každou podmínku inteligentní značku odstavce kód přidá vlastní inteligentní značky vlastnost a potom použije PersistTag metoda rozpoznávání inteligentních značek. Tento příklad předpokládá, že jste přidali odkaz na Microsoft.Office.Interop.SmartTag z .NET kartě Přidat odkaz dialogové okno. Příklad kódu je součástí větší příklad stanovené ISmartTagExtension rozhraní.
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);
}
}
}
Zabezpečení rozhraní .NET Framework
- Plná důvěra přímému volajícímu. Částečně zabezpečený kód nemůže tento člen použít. Další informace naleznete v tématu Používání knihoven z částečně důvěryhodného kódu.