override public void Run()
        {
            PlainSentence ps = null;

            try
            {
                while (true)
                {
                    ps = in_Renamed.Take();

                    if ((ps = plainTextProcessor.doProcess(ps)) != null)
                    {
                        out_Renamed.Add(ps);
                    }

                    while (plainTextProcessor.hasRemainingData())
                    {
                        if ((ps = plainTextProcessor.doProcess(null)) != null)
                        {
                            out_Renamed.Add(ps);
                        }
                    }

                    if ((ps = plainTextProcessor.flush()) != null)
                    {
                        out_Renamed.Add(ps);
                    }
                }
            }
            catch (System.Threading.ThreadInterruptedException e)
            {
                plainTextProcessor.shutdown();
            }
        }
Beispiel #2
0
        /// <summary> Returns the analysis result for one sentence at the top of the result queue. You can call this method
        /// repeatedly to get the result for remaining sentences in the input document. If there is no result,
        /// this method will be blocked until a new result comes.
        ///
        /// It stores the specified object with the analysis result. The return type of the object depends on the
        /// analysis phase of the work flow so you must give the relevant type of parameter.
        ///
        /// In this way, you can get the analysis result with a relevant object, so you don't need to parse the result string
        /// again. If you just want to see the result, consider to use "String getResultOfSentence()" instead.
        ///
        /// </summary>
        /// <param name="<T>">- One of PlainSentence (for the first phase), Sentence (for the second phase), and SetOfSentences (for the third phase).
        /// </param>
        /// <param name="a">- the object to get the result
        /// </param>
        /// <returns> the analysis result for one sentence at front
        /// </returns>
        /// <throws>  ResultTypeException </throws>
        public T getResultOfSentence <T>(T a) where T : class
        {
            Type objClass = a.GetType();

            try
            {
                if (typeof(PlainSentence).Equals(objClass))
                {
                    if (outputPhaseNum != 1)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <PlainSentence> queue = queuePhase1[outputQueueNum];
                    a = queue.Take() as T;
                }
                else if (typeof(SetOfSentences).Equals(objClass))
                {
                    if (outputPhaseNum != 2)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <SetOfSentences> queue = queuePhase2[outputQueueNum];
                    a = queue.Take() as T;
                }
                else if (typeof(Sentence).Equals(objClass))
                {
                    if (outputPhaseNum != 3)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <Sentence> queue = queuePhase3[outputQueueNum];
                    a = queue.Take() as T;
                }
                else
                {
                    throw new ResultTypeException(outputPhaseNum);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }

            return(a);
        }
Beispiel #3
0
        override public void Run()
        {
            Sentence sent = null;

            try
            {
                while (true)
                {
                    sent = in_Renamed.Take();

                    if ((sent = posProcessor.doProcess(sent)) != null)
                    {
                        out_Renamed.Add(sent);
                    }
                }
            }
            catch (System.Threading.ThreadInterruptedException e)
            {
                posProcessor.shutdown();
            }
        }
        override public void Run()
        {
            SetOfSentences sos = null;

            try
            {
                while (true)
                {
                    sos = in_Renamed.Take();

                    if ((sos = morphProcessor.doProcess(sos)) != null)
                    {
                        out_Renamed.Add(sos);
                    }
                }
            }
            catch (System.Threading.ThreadInterruptedException e)
            {
                morphProcessor.shutdown();
            }
        }
Beispiel #5
0
        override public void Run()
        {
            SetOfSentences sos  = null;
            Sentence       sent = null;

            try
            {
                while (true)
                {
                    sos = in_Renamed.Take();

                    if ((sent = tagger.tagPOS(sos)) != null)
                    {
                        out_Renamed.Add(sent);
                    }
                }
            }
            catch (System.Threading.ThreadInterruptedException e)
            {
                tagger.shutdown();
            }
        }
Beispiel #6
0
        override public void Run()
        {
            PlainSentence  ps  = null;
            SetOfSentences sos = null;

            try
            {
                while (true)
                {
                    ps = in_Renamed.Take();

                    if ((sos = ma.morphAnalyze(ps)) != null)
                    {
                        out_Renamed.Add(sos);
                    }
                }
            }
            catch (System.Threading.ThreadInterruptedException e)
            {
                ma.shutdown();
            }
        }
Beispiel #7
0
 public override void Run()
 {
     if (Log.IsDebugEnabled())
     {
         Log.Debug(GetName() + " started.");
     }
     CleanupQueue.PathDeletionContext context = null;
     while (true)
     {
         try
         {
             context = queue.Take();
             // delete the path.
             if (!DeletePath(context))
             {
                 Log.Warn("CleanupThread:Unable to delete path " + context.fullPath);
             }
             else
             {
                 if (Log.IsDebugEnabled())
                 {
                     Log.Debug("DELETED " + context.fullPath);
                 }
             }
         }
         catch (Exception)
         {
             Log.Warn("Interrupted deletion of " + context.fullPath);
             return;
         }
         catch (Exception e)
         {
             Log.Warn("Error deleting path " + context.fullPath + ": " + e);
         }
     }
 }
Beispiel #8
0
        /// <summary> Returns the analysis result list for all sentence in the result. When you use this method,
        /// you need to pay attention on the size of the data. If the size of data is big, it may show
        /// lower performance than using getResultOfSentence() repeatedly.
        ///
        /// The return type of the object depends on the analysis phase of the work flow so you must give
        /// the relevant type of parameter. In this way, you can get the analysis result with a relevant
        /// object, so you don't need to parse the result string again. If you just want to see the result,
        /// consider to use "String getResultOfDocument()" instead.
        ///
        /// </summary>
        /// <param name="<T>">- One of PlainSentence (for the first phase), Sentence (for the second phase), and SetOfSentences (for the third phase).
        /// </param>
        /// <param name="a">- the object to specify the return type
        /// </param>
        /// <returns> the list of the analysis result for all sentences in the document
        /// </returns>
        /// <throws>  ResultTypeException </throws>
        public LinkedList <T> getResultOfDocument <T>(T a)  where T : class
        {
            Type           objClass = a.GetType();
            LinkedList <T> list     = new LinkedList <T>();

            try
            {
                if (typeof(PlainSentence).Equals(objClass))
                {
                    if (outputPhaseNum != 1)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <PlainSentence> queue = queuePhase1[outputQueueNum];
                    while (true)
                    {
                        PlainSentence ps = queue.Take();
                        list.AddLast(ps as T);
                        if (ps.EndOfDocument)
                        {
                            break;
                        }
                    }
                }
                else if (typeof(SetOfSentences).Equals(objClass))
                {
                    if (outputPhaseNum != 2)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <SetOfSentences> queue = queuePhase2[outputQueueNum];
                    while (true)
                    {
                        SetOfSentences sos = queue.Take();
                        list.AddLast(sos as T);
                        if (sos.EndOfDocument)
                        {
                            break;
                        }
                    }
                }
                else if (typeof(Sentence).Equals(objClass))
                {
                    if (outputPhaseNum != 3)
                    {
                        throw new ResultTypeException(outputPhaseNum);
                    }
                    LinkedBlockingQueue <Sentence> queue = queuePhase3[outputQueueNum];
                    while (true)
                    {
                        Sentence sent = queue.Take();
                        list.AddLast(sent as T);
                        if (sent.EndOfDocument)
                        {
                            break;
                        }
                    }
                }
                else
                {
                    throw new ResultTypeException(outputPhaseNum);
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.ToString());
            }
            return(list);
        }