示例#1
0
        public override string ToString()
        {
            List <string> result = new List <string>();

            #region ToString
            if (Major != POSAnnotation.Major.Unknown)
            {
                result.Add(POSAnnotation.ToString(Major));
            }
            if (Type != POSAnnotation.Type.Unknown)
            {
                result.Add(POSAnnotation.ToString(Type));
            }
            if (Gender != POSAnnotation.Gender.Unknown)
            {
                result.Add(POSAnnotation.ToString(Gender));
            }
            if (Number != POSAnnotation.Number.Unknown)
            {
                result.Add(POSAnnotation.ToString(Number));
            }
            if (Case != POSAnnotation.Case.Unknown)
            {
                result.Add(POSAnnotation.ToString(Case));
            }
            if (Person != POSAnnotation.Person.Unknown)
            {
                result.Add(POSAnnotation.ToString(Person));
            }
            if (Finiteness != POSAnnotation.Finiteness.Unknown)
            {
                result.Add(POSAnnotation.ToString(Finiteness));
            }
            if (Mood != POSAnnotation.Mood.Unknown)
            {
                result.Add(POSAnnotation.ToString(Mood));
            }
            if (Tense != POSAnnotation.Tense.Unknown)
            {
                result.Add(POSAnnotation.ToString(Tense));
            }
            if (Voice != POSAnnotation.Voice.Unknown)
            {
                result.Add(POSAnnotation.ToString(Voice));
            }
            if (Status != POSAnnotation.Status.Unknown)
            {
                result.Add(POSAnnotation.ToString(Status));
            }
            if (Degree != POSAnnotation.Degree.Unknown)
            {
                result.Add(POSAnnotation.ToString(Degree));
            }
            if (Possessive != POSAnnotation.Possessive.Unknown)
            {
                result.Add(POSAnnotation.ToString(Possessive));
            }
            if (CategoryProDet != POSAnnotation.CategoryProDet.Unknown)
            {
                result.Add(POSAnnotation.ToString(CategoryProDet));
            }
            if (PronType != POSAnnotation.PronType.Unknown)
            {
                result.Add(POSAnnotation.ToString(PronType));
            }
            if (DetType != POSAnnotation.DetType.Unknown)
            {
                result.Add(POSAnnotation.ToString(DetType));
            }
            if (ArticleType != POSAnnotation.ArticleType.Unknown)
            {
                result.Add(POSAnnotation.ToString(ArticleType));
            }
            if (AdPosType != POSAnnotation.AdPosType.Unknown)
            {
                result.Add(POSAnnotation.ToString(AdPosType));
            }
            if (ConType != POSAnnotation.ConType.Unknown)
            {
                result.Add(POSAnnotation.ToString(ConType));
            }
            if (NumType != POSAnnotation.NumType.Unknown)
            {
                result.Add(POSAnnotation.ToString(NumType));
            }
            if (NumFunction != POSAnnotation.NumFunction.Unknown)
            {
                result.Add(POSAnnotation.ToString(NumFunction));
            }
            if (ResType != POSAnnotation.ResType.Unknown)
            {
                result.Add(POSAnnotation.ToString(ResType));
            }
            if (PuncType != POSAnnotation.PuncType.Unknown)
            {
                result.Add(POSAnnotation.ToString(PuncType));
            }
            #endregion
            return(result.Aggregate((left, right) => left + ", " + right));
        }
示例#2
0
        public static PartOfSpeech Parse(string value)
        {
            PartOfSpeech result      = new PartOfSpeech();
            var          annotations = value.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

            foreach (var annotation in annotations)
            {
                var annot     = POSAnnotation.Parse(annotation.Trim().ToUpper());
                var annotType = annot.GetType();

                #region Checking Annotation Type
                if (annotType == typeof(POSAnnotation.Major))
                {
                    if (result.Major != POSAnnotation.Major.Unknown)
                    {
                        throw new Exception("Major Annotation Redefinition");
                    }
                    result.Major = (POSAnnotation.Major)annot;
                }
                else if (annotType == typeof(POSAnnotation.Type))
                {
                    if (result.Type != POSAnnotation.Type.Unknown)
                    {
                        throw new Exception("Type Annotation Redefinition");
                    }
                    result.Type = (POSAnnotation.Type)annot;
                }
                else if (annotType == typeof(POSAnnotation.Gender))
                {
                    if (result.Gender != POSAnnotation.Gender.Unknown)
                    {
                        throw new Exception("Gender Annotation Redefinition");
                    }
                    result.Gender = (POSAnnotation.Gender)annot;
                }
                else if (annotType == typeof(POSAnnotation.Number))
                {
                    if (result.Number != POSAnnotation.Number.Unknown)
                    {
                        throw new Exception("Number Annotation Redefinition");
                    }
                    result.Number = (POSAnnotation.Number)annot;
                }
                else if (annotType == typeof(POSAnnotation.Case))
                {
                    if (result.Case != POSAnnotation.Case.Unknown)
                    {
                        throw new Exception("Case Annotation Redefinition");
                    }
                    result.Case = (POSAnnotation.Case)annot;
                }
                else if (annotType == typeof(POSAnnotation.Person))
                {
                    if (result.Person != POSAnnotation.Person.Unknown)
                    {
                        throw new Exception("Person Annotation Redefinition");
                    }
                    result.Person = (POSAnnotation.Person)annot;
                }
                else if (annotType == typeof(POSAnnotation.Finiteness))
                {
                    if (result.Finiteness != POSAnnotation.Finiteness.Unknown)
                    {
                        throw new Exception("Finiteness Annotation Redefinition");
                    }
                    result.Finiteness = (POSAnnotation.Finiteness)annot;
                }
                else if (annotType == typeof(POSAnnotation.Mood))
                {
                    if (result.Mood != POSAnnotation.Mood.Unknown)
                    {
                        throw new Exception("Mood Annotation Redefinition");
                    }
                    result.Mood = (POSAnnotation.Mood)annot;
                }
                else if (annotType == typeof(POSAnnotation.Tense))
                {
                    if (result.Tense != POSAnnotation.Tense.Unknown)
                    {
                        throw new Exception("Tense Annotation Redefinition");
                    }
                    result.Tense = (POSAnnotation.Tense)annot;
                }
                else if (annotType == typeof(POSAnnotation.Voice))
                {
                    if (result.Voice != POSAnnotation.Voice.Unknown)
                    {
                        throw new Exception("Voice Annotation Redefinition");
                    }
                    result.Voice = (POSAnnotation.Voice)annot;
                }
                else if (annotType == typeof(POSAnnotation.Status))
                {
                    if (result.Status != POSAnnotation.Status.Unknown)
                    {
                        throw new Exception("Status Annotation Redefinition");
                    }
                    result.Status = (POSAnnotation.Status)annot;
                }
                else if (annotType == typeof(POSAnnotation.Degree))
                {
                    if (result.Degree != POSAnnotation.Degree.Unknown)
                    {
                        throw new Exception("Degree Annotation Redefinition");
                    }
                    result.Degree = (POSAnnotation.Degree)annot;
                }
                else if (annotType == typeof(POSAnnotation.Possessive))
                {
                    if (result.Possessive != POSAnnotation.Possessive.Unknown)
                    {
                        throw new Exception("Possessive Annotation Redefinition");
                    }
                    result.Possessive = (POSAnnotation.Possessive)annot;
                }
                else if (annotType == typeof(POSAnnotation.CategoryProDet))
                {
                    if (result.CategoryProDet != POSAnnotation.CategoryProDet.Unknown)
                    {
                        throw new Exception("CategoryProDet Annotation Redefinition");
                    }
                    result.CategoryProDet = (POSAnnotation.CategoryProDet)annot;
                }
                else if (annotType == typeof(POSAnnotation.PronType))
                {
                    if (result.PronType != POSAnnotation.PronType.Unknown)
                    {
                        throw new Exception("PronType Annotation Redefinition");
                    }
                    result.PronType = (POSAnnotation.PronType)annot;
                }
                else if (annotType == typeof(POSAnnotation.DetType))
                {
                    if (result.DetType != POSAnnotation.DetType.Unknown)
                    {
                        throw new Exception("DetType Annotation Redefinition");
                    }
                    result.DetType = (POSAnnotation.DetType)annot;
                }
                else if (annotType == typeof(POSAnnotation.ArticleType))
                {
                    if (result.ArticleType != POSAnnotation.ArticleType.Unknown)
                    {
                        throw new Exception("ArticleType Annotation Redefinition");
                    }
                    result.ArticleType = (POSAnnotation.ArticleType)annot;
                }
                else if (annotType == typeof(POSAnnotation.AdPosType))
                {
                    if (result.AdPosType != POSAnnotation.AdPosType.Unknown)
                    {
                        throw new Exception("AdPosType Annotation Redefinition");
                    }
                    result.AdPosType = (POSAnnotation.AdPosType)annot;
                }
                else if (annotType == typeof(POSAnnotation.ConType))
                {
                    if (result.ConType != POSAnnotation.ConType.Unknown)
                    {
                        throw new Exception("ConType Annotation Redefinition");
                    }
                    result.ConType = (POSAnnotation.ConType)annot;
                }
                else if (annotType == typeof(POSAnnotation.NumType))
                {
                    if (result.NumType != POSAnnotation.NumType.Unknown)
                    {
                        throw new Exception("NumType Annotation Redefinition");
                    }
                    result.NumType = (POSAnnotation.NumType)annot;
                }
                else if (annotType == typeof(POSAnnotation.NumFunction))
                {
                    if (result.NumFunction != POSAnnotation.NumFunction.Unknown)
                    {
                        throw new Exception("NumFunction Annotation Redefinition");
                    }
                    result.NumFunction = (POSAnnotation.NumFunction)annot;
                }
                else if (annotType == typeof(POSAnnotation.ResType))
                {
                    if (result.ResType != POSAnnotation.ResType.Unknown)
                    {
                        throw new Exception("ResType Annotation Redefinition");
                    }
                    result.ResType = (POSAnnotation.ResType)annot;
                }
                else if (annotType == typeof(POSAnnotation.PuncType))
                {
                    if (result.PuncType != POSAnnotation.PuncType.Unknown)
                    {
                        throw new Exception("PuncType Annotation Redefinition");
                    }
                    result.PuncType = (POSAnnotation.PuncType)annot;
                }
                #endregion
            }
            return(result);
        }