Пример #1
0
        public static void Main()
        {
            presage_csharp_demo demo = new presage_csharp_demo();

            try
            {
                Presage prsg = new Presage
                               (
                    demo.callback_get_past_stream,
                    demo.callback_get_future_stream,
                    "presage_csharp_demo.xml"
                               );

                System.Console.WriteLine("predict: ");
                foreach (string str in prsg.predict())
                {
                    System.Console.WriteLine("    " + str);
                }

                System.Console.WriteLine("context: " + prsg.context());

                System.Console.WriteLine("prefix: " + prsg.prefix());

                System.Console.WriteLine("context_change: " + prsg.context_change());

                System.Console.WriteLine("completion: " + prsg.completion("future"));

                System.Console.WriteLine("suggestions: " + prsg.get_config("Presage.Selector.SUGGESTIONS"));

                prsg.set_config("Presage.Selector.SUGGESTIONS", "10");

                System.Console.WriteLine("suggestions: " + prsg.get_config("Presage.Selector.SUGGESTIONS"));

                prsg.learn("Prediction is very difficult, especially about the future.");

                System.Console.WriteLine("predict: ");
                foreach (string str in prsg.predict())
                {
                    System.Console.WriteLine("    " + str);
                }

                prsg.save_config();

                System.Console.WriteLine("version: " + prsg.version());
            }
            catch (PresageException ex)
            {
                System.Console.WriteLine("Caught presage exception: {0}", ex.ToString());
            }
        }
        public override IEnumerable <string> GetSuggestions(string root, bool nextWord)
        {
            Log.DebugFormat("GetSuggestions called with root '{0}'", root);

            if (root == null)
            {
                this.root = "";
            }
            else
            {
                this.root = root;

                // force presage to suggest the next word by adding a space
                if (nextWord && root.Length > 0 && char.IsLetterOrDigit(root.Last()))
                {
                    this.root = this.root + " ";
                }
            }

            if (prsg != null)
            {
                return(prsg.predict());
            }

            return(Enumerable.Empty <string>());
        }
Пример #3
0
        public override IEnumerable <string> GetSuggestions(string root, bool nextWord)
        {
            Log.DebugFormat("GetSuggestions called with root '{0}'", root);

            try
            {
                if (root == null)
                {
                    this.root = "";
                }
                else
                {
                    this.root = root;

                    // force presage to suggest the next word by adding a space
                    if (nextWord && root.Length > 0 && char.IsLetterOrDigit(root.Last()))
                    {
                        this.root = this.root + " ";
                    }
                }

                if (prsg != null)
                {
                    return(prsg.predict());
                }
            }
            catch (PresageException pe)
            {
                Log.Error("PresageException caught. Rethrowing. This is an attempt to see why the PresageException is not being caught. PresageException:", pe);
                throw;
            }

            return(Enumerable.Empty <string>());
        }
Пример #4
0
 public string[] predict()
 {
     return(prsg.predict());
 }
Пример #5
0
 public String[] getPredictions(string inputString)
 {
     buffer = inputString;
     return(presage.predict());
 }