コード例 #1
0
ファイル: WordDAOTests.cs プロジェクト: Argh4k/ProgramTech
 public static void intialize(TestContext tc)
 {
     DatabaseController.getInstance().removeTable(tableName);
     DatabaseController.getInstance().addTable(tableName);
     Word.setScoringHandler(new ScoringHandler("../../ScoringHandlerDaoTests.xml"));
     testWords = new List <Word>(new Word[] { new Word("Daddy"), new Word("Mom"), new Word("Dnow"), new Word("Grandpa") });
     testDao   = new WordDAO();
     foreach (Word word in testWords)
     {
         testDao.save(word, tableName);
     }
 }
コード例 #2
0
        /// <summary>
        /// Check if the word is spelled correctly
        /// </summary>
        /// <param name="word"></param>
        /// <returns></returns>
        public bool DoesWordExist(Word word)
        {
            if (word.Spell == null || word == null)
            {
                return(false);
            }

            word = new WordDAO().Query(word);
            if (word == null || word.Id == 0)
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
コード例 #3
0
        /// <summary>
        /// Recursively checking for partial fit of given word
        /// Add result and rank (levenshtein distance) to a given dictionary
        /// </summary>
        /// <param name="word"></param>
        /// <param name="LevenshteinDistance"></param>
        /// <param name="suggestionDict"></param>
        public void GetSpellSuggestions(string word, int LevenshteinDistance, Dictionary <string, int> suggestionDict)
        {
            if (word.Length < 3)
            {
                return;
            }
            List <Word> partialMatch = new WordDAO().FindPartialMatch(word);

            foreach (Word w in partialMatch)
            {
                if (!suggestionDict.Keys.Contains(w.Spell))
                {
                    suggestionDict[w.Spell] = LevenshteinDistance;
                }
            }
            GetSpellSuggestions(word.Substring(1), LevenshteinDistance + 1, suggestionDict);
            GetSpellSuggestions(word.Substring(0, word.Length - 1), LevenshteinDistance + 1, suggestionDict);
        }
コード例 #4
0
        /// <summary>
        /// Init DB
        /// </summary>
        private void LoadData()
        {
            new WordDAO().CreateTable();
            new CommonMisspellDAO().CreateTable();
            Word apple = new Word()
            {
                Spell = "Apple"
            };
            Word people = new Word()
            {
                Spell = "People"
            };

            apple  = new WordDAO().Insert(apple);
            people = new WordDAO().Insert(people);
            new CommonMisspellDAO().Insert(new CommonMisspell()
            {
                FullWordId = apple.Id, Spell = "appla"
            });
            //List<SpellCheckSuggestion> suggestionsList = GetSpellSuggestions(new Word() { Spell = "Zpple" });
        }
コード例 #5
0
ファイル: WordBLL.cs プロジェクト: Wesley95/PIMDesktopProject
 public static List <WordDTO> ListAll() =>
 WordDAO.ListAll();