public static string ToShortString(this PartOfSpeech pos)
        {
            switch (pos)
            {
            case PartOfSpeech.Unknown:      return(PrgResources.POFShortUnknown);

            case PartOfSpeech.Noun:         return(PrgResources.POFShortNoun);

            case PartOfSpeech.Pronoun:      return(PrgResources.POFShortPronoun);

            case PartOfSpeech.Verb:         return(PrgResources.POFShortVerb);

            case PartOfSpeech.Adjective:    return(PrgResources.POFShortAdjective);

            case PartOfSpeech.Adverb:       return(PrgResources.POFShortAdverb);

            case PartOfSpeech.Preposition:  return(PrgResources.POFShortPreposition);

            case PartOfSpeech.Conjunction:  return(PrgResources.POFShortConjunction);

            case PartOfSpeech.Interjection: return(PrgResources.POFShortInterjection);

            default:
                return(pos.ToString());
            }
        }
Пример #2
0
        // Summary:
        //     Retrieves words from dictionary by word syllables schema and part of speech type.
        //
        // Parameters:
        //   syllablesSchema:
        //     The syllables schema of the word to be retrieved.
        //   type:
        //     PartOfSpeech object representing the type of word.
        // Returns:
        //     The list of Word objects.
        public List <Word> GetWords(string syllablesSchema, PartOfSpeech type)
        {
            string      query        = "select id, word, syllables, type from Dictionary where syllables = @syllablesSchema and type = @type";
            List <Word> matchedWords = new List <Word>();

            using (SqlConnection connection = new SqlConnection(connectionString))
            {
                connection.Open();
                using (SqlCommand command = new SqlCommand(query, connection))
                {
                    command.Parameters.Add(new SqlParameter("@syllablesSchema", syllablesSchema));
                    command.Parameters.Add(new SqlParameter("@type", type.ToString()));

                    SqlDataReader reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        int    id        = reader.GetInt32(0);
                        string word      = reader.GetString(1);
                        string syllables = reader.GetString(2);
                        string type1     = reader.GetString(3);

                        PartOfSpeech partOfSpeech;
                        if (Enum.TryParse(type1, out partOfSpeech))
                        {
                            matchedWords.Add(new Word {
                                Id = id, Value = word, Syllables = syllables, PartOfSpeech = partOfSpeech
                            });
                        }
                    }
                }
            }

            return(matchedWords);
        }
        public static string ToFullString(this PartOfSpeech pos)
        {
            switch (pos)
            {
            case PartOfSpeech.Unknown:      return(PrgResources.POFFullUnknown);

            case PartOfSpeech.Noun:         return(PrgResources.POFFullNoun);

            case PartOfSpeech.Pronoun:      return(PrgResources.POFFullPronoun);

            case PartOfSpeech.Verb:         return(PrgResources.POFFullVerb);

            case PartOfSpeech.Adjective:    return(PrgResources.POFFullAdjective);

            case PartOfSpeech.Adverb:       return(PrgResources.POFFullAdverb);

            case PartOfSpeech.Preposition:  return(PrgResources.POFFullPreposition);

            case PartOfSpeech.Conjunction:  return(PrgResources.POFFullConjunction);

            case PartOfSpeech.Interjection: return(PrgResources.POFFullInterjection);

            default:
                return(pos.ToString());
            }
        }
Пример #4
0
        public static string PartOfSpeechToString(PartOfSpeech pos)
        {
            var naive  = pos.ToString();
            var result = new StringBuilder();

            for (var i = 0; i < naive.Length; i++)
            {
                if (i > 0 && char.IsUpper(naive[i]))
                {
                    result.Append(' ');
                }

                result.Append(naive[i]);
            }

            return(result.ToString());
        }