Exemple #1
0
        public void Danish_BaseTest()
        {
            DanishStemmer stemmer = new DanishStemmer();

            Assert.AreEqual("abrænd", stemmer.Stem("abrændes"));
            Assert.AreEqual("barnløs", stemmer.Stem("barnløst"));
        }
        public void SetStemmer(DanishStemmer stemmer)
        {
            if (stemmer == null)
            {
                return;
            }

            Stemmer = stemmer;
        }
 public DanishStemFilter(TokenStream tokenStream)
     : base(tokenStream)
 {
     Stemmer       = new DanishStemmer();
     TermAttribute = AddAttribute <ITermAttribute>();
 }
 protected internal virtual void copy_from(DanishStemmer other)
 {
     I_p1 = other.I_p1;
     S_ch = other.S_ch;
     base.copy_from(other);
 }
        /// <summary>
        /// 获取词干对象(线程不安全)
        /// </summary>
        /// <param name="language"></param>
        /// <returns></returns>
        //public static SnowballProgram GetSnowball(string language)
        //{
        //    if (_dictSnowball.ContainsKey(language))
        //        return _dictSnowball[language];
        //    return null;
        //}
        /// <summary>
        /// 获取词干对象(线程安全)
        /// </summary>
        /// <param name="language"></param>
        /// <returns></returns>
        public static SnowballProgram GetSnowball(string language)
        {
            SnowballProgram result = null;

            switch (language)
            {
            case "DA":
                result = new DanishStemmer();
                break;    //丹麦语

            case "NL":
                result = new DutchStemmer();
                break;    //荷兰语

            case "EN":
                result = new EnglishStemmer();
                break;    //英语

            case "FI":
                result = new FinnishStemmer();
                break;    //芬兰语

            case "FR":
                result = new FrenchStemmer();
                break;    //法语

            case "DE2":
                result = new German2Stemmer();
                break;    //德语2

            case "DE":
                result = new GermanStemmer();
                break;    //德语

            case "HU":
                result = new HungarianStemmer();
                break;

            case "IT":
                result = new ItalianStemmer();
                break;

            case "文斯语":
                result = new LovinsStemmer();
                break;

            case "NO":
                result = new NorwegianStemmer();
                break;

            case "波特语":
                result = new PorterStemmer();
                break;    //英语的

            case "PT":
                result = new PortugueseStemmer();
                break;    //葡萄牙语

            case "RO":
                result = new RomanianStemmer();
                break;

            case "RU":
                result = new RussianStemmer();
                break;    //俄语

            case "ES":
                result = new SpanishStemmer();
                break;    //西班牙语

            case "SV":
                result = new SwedishStemmer();
                break;

            case "TR":
                result = new TurkishStemmer();
                break;    //土耳其语
            }
            return(result);
        }
Exemple #6
0
        public IEnumerable <String> Stem(IEnumerable <String> tokensToStem)
        {
            Stemmer stemmer = new DanishStemmer();

            return(stemmer.GetSteamWords(tokensToStem.ToArray()));
        }
Exemple #7
-4
    } // End of the GetCurrentDomain method

    /// <summary>
    /// Get the stemmer based on the language
    /// </summary>
    /// <param name="language">A reference to the language</param>
    /// <returns>A reference to a Stemmer</returns>
    public static Stemmer GetStemmer(Language language)
    {
        // Create a default stemmer
        Stemmer stemmer = new DefaultStemmer();

        // Get the language code in lower case
        string language_code = language.language_code.ToLower();

        // Get a stemmer depending on the language
        if (language_code == "da")
        {
            stemmer = new DanishStemmer();
        }
        else if (language_code == "nl")
        {
            stemmer = new DutchStemmer();
        }
        else if (language_code == "en")
        {
            stemmer = new EnglishStemmer();
        }
        else if (language_code == "fi")
        {
            stemmer = new FinnishStemmer();
        }
        else if (language_code == "fr")
        {
            stemmer = new FrenchStemmer();
        }
        else if (language_code == "de")
        {
            stemmer = new GermanStemmer();
        }
        else if (language_code == "it")
        {
            stemmer = new ItalianStemmer();
        }
        else if (language_code == "no")
        {
            stemmer = new NorwegianStemmer();
        }
        else if (language_code == "pt")
        {
            stemmer = new PortugueseStemmer();
        }
        else if (language_code == "ro")
        {
            stemmer = new RomanianStemmer();
        }
        else if (language_code == "es")
        {
            stemmer = new SpanishStemmer();
        }
        else if (language_code == "sv")
        {
            stemmer = new SwedishStemmer();
        }

        // Return the stemmer
        return stemmer;

    } // End of the GetStemmer method