示例#1
0
        public ArrayList SearchSynonyms(string word, string language)
        {
            ArrayList synonyms = new ArrayList();

            if (language.Equals("spanish"))
            {
                if (word.EndsWith("es"))
                {
                    // plural?
                    string maybeSynonymous = word.Substring(0, word.Length - 2);
                    Word   wrd             = Word.Load(cnn, maybeSynonymous);
                    if (wrd != null)
                    {
                        synonyms.Add(wrd);
                    }
                }
                if (word.EndsWith("s"))
                {
                    // plural?
                    string maybeSynonymous = word.Substring(0, word.Length - 1);
                    Word   wrd             = Word.Load(cnn, maybeSynonymous);
                    if (wrd != null)
                    {
                        synonyms.Add(wrd);
                    }
                }
                else
                {
                    // not plural
                    string maybeSynonymous = word + "es";
                    Word   wrd             = Word.Load(cnn, maybeSynonymous);
                    if (wrd != null)
                    {
                        synonyms.Add(wrd);
                    }
                    else
                    {
                        maybeSynonymous = word + "s";
                        wrd             = Word.Load(cnn, maybeSynonymous);
                        if (wrd != null)
                        {
                            synonyms.Add(wrd);
                        }
                    }
                }
            }
            if (language.Equals("english"))
            {
                if (word.EndsWith("s"))
                {
                    // plural?
                    string maybeSynonymous = word.Substring(0, word.Length - 1);
                    Word   wrd             = Word.Load(cnn, maybeSynonymous);
                    if (wrd != null)
                    {
                        synonyms.Add(wrd);
                    }
                }
                else
                {
                    // not plural
                    string maybeSynonymous = word + "s";
                    Word   wrd             = Word.Load(cnn, maybeSynonymous);
                    if (wrd != null)
                    {
                        synonyms.Add(wrd);
                    }
                }
            }
            return(synonyms);
        }
示例#2
0
        public void DumpToDatabase(DbConnection connection , Document doc)
        {
            IDictionaryEnumerator e = table.GetEnumerator();
            while (e.MoveNext())
            {
                // Get the DB word:
                string wordText = (string)e.Key;
                Word word = Word.Load(connection, wordText);
                if (word == null)
                {
                    word = new Word(wordText);
                    word.Insert(connection);
                }

                // Store the counter.
                Counter cnt = (Counter)e.Value;
                WordInstance inst = new WordInstance(word.Code, doc.Code, cnt.Count, cnt.Positions);
                inst.Insert(connection);
            }
        }