Ejemplo n.º 1
0
        /// <summary> It extracts the morphemes which were recognized as noun after POS tagging.</summary>
        /// <param name="st">- the POS tagged sentence
        /// </param>
        /// <returns> the sentence in which only nouns were remained
        /// </returns>
        public virtual Sentence doProcess(Sentence st)
        {
            Eojeol[] eojeols = st.Eojeols;

            for (int i = 0; i < eojeols.Length; i++)
            {
                System.String[] morphemes = eojeols[i].Morphemes;
                System.String[] tags      = eojeols[i].Tags;
                nounMorphemes.Clear();
                nounTags.Clear();

                for (int j = 0; j < tags.Length; j++)
                {
                    char c = tags[j][0];
                    if (c == 'n')
                    {
                        nounMorphemes.AddLast(morphemes[j]);
                        nounTags.AddLast(tags[j]);
                    }
                    else if (c == 'f')
                    {
                        nounMorphemes.AddLast(morphemes[j]);
                        nounTags.AddLast("ncn");
                    }
                }

                eojeols[i].Morphemes = nounMorphemes.ToArray();
                eojeols[i].Tags      = nounTags.ToArray();
            }

            st.Eojeols = eojeols;

            return(st);
        }
Ejemplo n.º 2
0
        /// <summary> It extracts the morphemes which were recognized as noun after POS tagging.</summary>
        /// <param name="st">- the POS tagged sentence
        /// </param>
        /// <returns> the sentence in which only nouns were remained
        /// </returns>
        public virtual Sentence doProcess(Sentence st)
        {
            Eojeol[] eojeols = st.Eojeols;

            for (int i = 0; i < eojeols.Length; i++)
            {
                System.String[] morphemes = eojeols[i].Morphemes;
                System.String[] tags = eojeols[i].Tags;
                nounMorphemes.Clear();
                nounTags.Clear();

                for (int j = 0; j < tags.Length; j++)
                {
                    char c = tags[j][0];
                    if (c == 'n')
                    {
                        nounMorphemes.AddLast(morphemes[j]);
                        nounTags.AddLast(tags[j]);
                    }
                    else if (c == 'f')
                    {
                        nounMorphemes.AddLast(morphemes[j]);
                        nounTags.AddLast("ncn");
                    }
                }

                eojeols[i].Morphemes = nounMorphemes.ToArray();
                eojeols[i].Tags = nounTags.ToArray();
            }

            st.Eojeols = eojeols;

            return st;
        }
Ejemplo n.º 3
0
        /// <summary> It changes the POS tagging result with 69 KAIST tags to the simplified result with 9 tags.</summary>
        /// <param name="st">- the result of morphological analysis where each eojeol has more than analysis result
        /// </param>
        /// <returns> the simplified POS tagging result
        /// </returns>
        public virtual Sentence doProcess(Sentence st)
        {
            System.String prevTag = null;
            bool changed = false;

            Eojeol[] eojeolSet = st.Eojeols;

            for (int i = 0; i < eojeolSet.Length; i++)
            {
                System.String[] tags = eojeolSet[i].Tags;
                prevTag = "";
                changed = false;

                for (int j = 0; j < tags.Length; j++)
                {
                    tags[j] = TagMapper.getKaistTagOnLevel(tags[j], TAG_LEVEL);

                    if (tags[j].Equals(prevTag))
                    {
                        changed = true;
                    }
                    prevTag = tags[j];
                }

                if (changed)
                {
                    tagList.Clear();
                    morphemeList.Clear();
                    System.String[] morphemes = eojeolSet[i].Morphemes;

                    for (int j = 0; j < tags.Length - 1; j++)
                    {
                        if (tags[j].Equals(tags[j + 1]))
                        {
                            morphemes[j + 1] = morphemes[j] + morphemes[j + 1];
                        }
                        else
                        {
                            tagList.Add(tags[j]);
                            morphemeList.Add(morphemes[j]);
                        }
                    }
                    tagList.Add(tags[tags.Length - 1]);
                    morphemeList.Add(morphemes[morphemes.Length - 1]);

                    eojeolSet[i] = new Eojeol(morphemeList.ToArray(), tagList.ToArray());
                }
            }
            st.Eojeols = eojeolSet;

            return st;
        }
Ejemplo n.º 4
0
        /// <summary> It changes the POS tagging result with 69 KAIST tags to the simplified result with 9 tags.</summary>
        /// <param name="st">- the result of morphological analysis where each eojeol has more than analysis result
        /// </param>
        /// <returns> the simplified POS tagging result
        /// </returns>
        public virtual Sentence doProcess(Sentence st)
        {
            System.String prevTag = null;
            bool          changed = false;

            Eojeol[] eojeolSet = st.Eojeols;

            for (int i = 0; i < eojeolSet.Length; i++)
            {
                System.String[] tags = eojeolSet[i].Tags;
                prevTag = "";
                changed = false;

                for (int j = 0; j < tags.Length; j++)
                {
                    tags[j] = TagMapper.getKaistTagOnLevel(tags[j], TAG_LEVEL);

                    if (tags[j].Equals(prevTag))
                    {
                        changed = true;
                    }
                    prevTag = tags[j];
                }

                if (changed)
                {
                    tagList.Clear();
                    morphemeList.Clear();
                    System.String[] morphemes = eojeolSet[i].Morphemes;

                    for (int j = 0; j < tags.Length - 1; j++)
                    {
                        if (tags[j].Equals(tags[j + 1]))
                        {
                            morphemes[j + 1] = morphemes[j] + morphemes[j + 1];
                        }
                        else
                        {
                            tagList.Add(tags[j]);
                            morphemeList.Add(morphemes[j]);
                        }
                    }
                    tagList.Add(tags[tags.Length - 1]);
                    morphemeList.Add(morphemes[morphemes.Length - 1]);

                    eojeolSet[i] = new Eojeol(morphemeList.ToArray(), tagList.ToArray());
                }
            }
            st.Eojeols = eojeolSet;

            return(st);
        }
Ejemplo n.º 5
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();
            }
        }
Ejemplo n.º 6
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();
            }
        }