コード例 #1
0
        public Collection <NounPhrase> SplitIntoNounPhrases(string text)
        {
            Collection <NounPhrase> subjects = new Collection <NounPhrase>();

            if (text.Length == 0)
            {
                return(subjects);
            }

            text = text.Trim();



            if (!text.Contains(" pi ")) //|| text.Contains(" pu ");
            {
                subjects.Add(new NounPhrase(text));
                return(subjects);
            }

            int offset = 0;

            for (int i = 0; i < text.Length; i++)
            {
                if (text.Substring(i).StartsWith(" pi "))
                {
                    NounPhrase s = ExtractNounPhrase(text, i, offset);
                    //s.Type = SubjectType.And;
                    subjects.Add(s);
                    offset = i + 4;
                }

                if (!text.Substring(offset).Contains(" pi "))
                {
                    NounPhrase s = new NounPhrase(text.Substring(offset));
                    s.Type = NpType.Pi;
                    subjects.Add(s);
                    break;
                }

                //Subordinate
                //if (text.Substring(i).StartsWith(" pu "))
                //{
                //    NounPhrase s = ExtractNounPhrase(text, i, offset);
                //    subjects.Add(s);
                //    //s.Type = SubjectType.Or;
                //    offset = i + 5;
                //}
            }

            return(subjects);
        }
コード例 #2
0
        private NounPhrase ExtractNounPhrase(string text, int i, int offset)
        {
            NounPhrase s = new NounPhrase(text.Substring(offset, i - offset));

            return(s);
        }