Example #1
0
        public bool OnParseCurrentWord(object argument)
        {
            CheckDisposed();

            WfiWordform wf = CurrentWordform;

            if (wf == null)
            {
                MessageBox.Show(ParserUIStrings.ksSelectWordFirst);
            }
            else
            {
                if (Connection == null)
                {
                    ConnectToParser(false);
                }
                else
                {
                    ParserScheduler parser = Connection.Parser;
                    if (parser != null)
                    {
                        parser.LoadGrammarAndLexiconIfNeeded();
                    }
                }
                UpdateWordformAsap(wf);
            }

            return(true);               //we handled this.
        }
Example #2
0
        //this is invoked by the parser connection, on our own event handling thread.
        protected void ParserUpdateHandler(ParserScheduler parser, TaskReport task)
        {
            Trace.WriteLine("   In ParserUpdateHandler");
            try
            {
                switch (task.Phase)
                {
                case TaskReport.TaskPhase.started:
                    m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix;
                    Trace.WriteLine("   started: " + task.Description);
                    break;

                case TaskReport.TaskPhase.finished:
                    m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix;
                    Trace.WriteLine("   finished: " + task.Description);
                    Trace.WriteLine("   finished: Duration: " + task.DurationSeconds.ToString() + " seconds");
                    Trace.WriteLineIf(task.Details != null, "finished: Details: " + task.Details);

                    break;

                default:
                    m_lblStatus.Text = m_sParserStatusPrefix + task.Description + m_sParserStatusSuffix;
                    Trace.WriteLine("   default: " + task.Description + "    " + task.PhaseDescription);
                    break;
                }
            }
            catch (ObjectDisposedException ode)
            {
                // By the time we get any "finished" tasks, they have been disposed.  Ignore them.
                Trace.WriteLine("   " + ode.Message);
                Trace.WriteLine("   " + ode.StackTrace);
            }
        }
Example #3
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            AutoMapperConfig.Initialize();
            ParserScheduler.Start();
        }
Example #4
0
        //this is invoked by the parser connection, on our own event handling thread.
        protected void ParserUpdateHandler(ParserScheduler parser, TaskReport task)
        {
            if (m_previousTask != task)
            {
                m_log.Text += "\r\n";
                Debug.WriteLine("");
            }

            string pad = "";

            for (int i = task.Depth; i > 0; i--)
            {
                pad += "    ";
            }
            m_log.Text += pad;

            switch (task.Phase)
            {
            case TaskReport.TaskPhase.started:
                m_log.Text += task.Description + " ";                      //+pad + "{\r\n";
                Debug.Write(task.Description + " ");
                break;

            case TaskReport.TaskPhase.finished:
                if (m_previousTask != task)
                {
                    m_log.Text += " ^ ";
                }
                m_log.Text += task.DurationSeconds.ToString() + " seconds";
                Debug.Write(task.DurationSeconds.ToString() + " seconds");
                //m_log.Text += "}\r\n";
                if (task.Details != null)
                {
                    m_log.Text += "Details:" + task.Details;
                }

                break;

            default:
                m_log.Text += task.Description + "    " + task.PhaseDescription;                        //+ "\r\n";
                Debug.Write(task.Description + "    " + task.PhaseDescription);
                break;
            }
            m_log.Select(m_log.Text.Length, 0);
            m_log.ScrollToCaret();

            m_previousTask = task;
        }
Example #5
0
        public bool OnDisplayReparseAllWords(object commandObject, ref UIItemDisplayProperties display)
        {
            CheckDisposed();

            ParserConnection con    = Connection;
            ParserScheduler  parser = null;

            if (con != null)
            {
                parser = con.Parser;
            }
            // must wait for the queue to empty before we can fill it up again or else we run the risk of breaking the parser thread
            display.Enabled = ((con != null) && (parser != null) &&
                               parser.GetQueueSize(ParserScheduler.Priority.eventually) == 0);

            return(true);               //we handled this.
        }
Example #6
0
        public bool OnReparseAllWords(object argument)
        {
            CheckDisposed();

            ParserConnection con = Connection;

            if (con != null)
            {
                ParserScheduler parser = con.Parser;
                if (parser != null)
                {
                    parser.ParseAllWordforms = true;
                    parser.LoadGrammarAndLexiconIfNeeded();
                    parser.InvalidateAllWordforms();
                }
            }
            return(true);               //we handled this.
        }
Example #7
0
        /// <summary>
        /// Put all (unique) wordforms of the text in the medium priority queue of the Parser
        /// </summary>
        /// <param name="text"></param>
        public void UpdateWordformsInText(StText text)
        {
            CheckDisposed();

            int[] aiWordformHvos = text.UniqueWordforms();

            ParserConnection con = Connection;

            if (con != null)
            {
                ParserScheduler parser = con.Parser;
                if (parser != null)
                {
                    parser.LoadGrammarAndLexiconIfNeeded();
                    parser.ScheduleWordformsForUpdate(aiWordformHvos, WordWorks.Parser.ParserScheduler.Priority.soon);
                }
            }
        }
Example #8
0
 public AdminController(ParserScheduler scheduler)
 {
     parserScheduler = scheduler;
     token           = cts.Token;
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParserConnection"/> class.
 /// This will attempt to connect to an existing parser or start a new one if necessary.
 /// </summary>
 public ParserConnection(LcmCache cache, IdleQueue idleQueue)
 {
     m_activity  = "";
     m_scheduler = new ParserScheduler(cache, idleQueue, Path.Combine(FwDirectoryFinder.CodeDirectory, FwDirectoryFinder.ksFlexFolderName));
     m_scheduler.ParserUpdateVerbose += ParserUpdateHandlerForPolling;
 }
Example #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ParserConnection"/> class.
 /// This will attempt to connect to an existing parser or start a new one if necessary.
 /// </summary>
 public ParserConnection(FdoCache cache, IdleQueue idleQueue)
 {
     m_activity  = "";
     m_scheduler = new ParserScheduler(cache, idleQueue);
     m_scheduler.ParserUpdateVerbose += ParserUpdateHandlerForPolling;
 }