Esempio n. 1
0
        public void Recognize(
            string Text,
            SmartTagLib.IF_TYPE DataType,
            int LocaleID,
            SmartTagLib.ISmartTagRecognizerSite RecognizerSite)
        {
            // The Recognize method is called and passed a text value.
            // We must search for recognized strings in the text in order
            // to set up the set of possible actions.
            int i;
            int startpos;
            int strlen;

            SmartTagLib.ISmartTagProperties propbag;

            int count = numericStrings.Length;

            for (i = 0; i < count; i++)
            {
                // See if this Text string matches any groceries.
                startpos = Text.IndexOf(numericStrings[i]) + 1;
                strlen   = numericStrings[i].Length;
                while (startpos > 0)
                {
                    // Commit the Smart Tag to the property bag.
                    propbag = RecognizerSite.GetNewPropertyBag();
                    RecognizerSite.CommitSmartTag(
                        "Contoso/TestSmartTagRecognizerAction#Symbols",
                        startpos, strlen, propbag);

                    // Continue looking for matches.
                    startpos = Text.IndexOf(numericStrings[i], startpos + strlen) + 1;
                }
            }
        }
Esempio n. 2
0
        protected override void Recognize(string text, Microsoft.Office.Interop.SmartTag.ISmartTagRecognizerSite site, Microsoft.Office.Interop.SmartTag.ISmartTagTokenList tokenList)
        {
            /*int pos = text.IndexOf((char)65532);
             * if (pos != -1)
             * {
             *  text = text.Substring(0, pos);
             * }
             * if (text==null || text == "")
             * {
             *  return;
             * }
             * if (isToken(text))
             * {
             *  String[] tokens = SmartTagProxy.SmartTag.getTokens(text);
             *  ISmartTagProperties propertyBag = site.GetNewPropertyBag();
             *  foreach(String stoken in tokens)
             *  {
             *      int startIndex = text.IndexOf(stoken);
             *      int endIndex = startIndex + stoken.Length;
             *      Terms.Add(stoken);
             *      propertyBag.Write("token", stoken);
             *      this.PersistTag(startIndex, endIndex, propertyBag);
             *  }
             * }*/

            ISmartTagProperties propertyBag = site.GetNewPropertyBag();

            for (int i = 1; i <= tokenList.Count; i++)
            {
                ISmartTagToken token = tokenList.get_Item(i);
                if (isToken(token.Text))
                {
                    string stoken     = token.Text;
                    int    startIndex = text.IndexOf(stoken);
                    int    endIndex   = startIndex + stoken.Length;

                    propertyBag.Write("token", stoken);
                    this.Terms.Add(stoken);
                }
            }
        }