示例#1
0
        /// <summary>
        /// Perform spell checking using the existing spell checker.
        /// If the spell checker is not initialised correctly throw an exception.
        /// </summary>
        /// <param name="sentence"></param>
        /// <returns></returns>
        public SpellingCorrectionResult CorrectSpelling(string[] sentence)
        {
            if (_spellChecker == null)
            {
                throw new SoapException("Spell Checker Model is not Initialised", null);
            }
            var results = _spellChecker.CheckSpelling(sentence);
            List <SpellingCorrection> corrections = new List <SpellingCorrection>();

            foreach (var result in results)
            {
                corrections.Add(new SpellingCorrection(result));
            }
            return(new SpellingCorrectionResult(sentence, corrections));
        }