示例#1
0
        private String applyRules(String st, SuffixTree <SavoyRule> rules)
        {
            int length = st.Length - 1;

            if (length < rules.Properties["size"])              //If the word is smaller than the minimum stemming size of this step, ignore it
            {
                return(st);
            }

            List <Pair <String, SavoyRule> > res = rules.getLongestSuffixesAndValues(st);

            for (int i = res.Count - 1; i >= 0; i--)
            {
                Pair <String, SavoyRule> r = res[i];
                String    suffix           = r.First;
                SavoyRule rule             = r.Second;
                if (length > rule.size)
                {
                    return(st.Substring(0, st.Length - suffix.Length) + rule.replacement);
                }
            }
            return(st);
        }
示例#2
0
        private String applyRules(String st, SuffixTree <Rule> rules)
        {
            if (st.Length < rules.Properties["size"])                   //If the word is smaller than the minimum stemming size of this step, ignore it
            {
                return(st);
            }

            List <Pair <String, Rule> > res = rules.getLongestSuffixesAndValues(st);

            for (int i = res.Count - 1; i >= 0; i--)
            {
                Pair <String, Rule> r = res[i];
                String suffix         = r.First;
                Rule   rule           = r.Second;

                if (rules.Properties["exceptions"] == 1)                        //Compare entire word with exceptions
                {
                    if (rule.exceptions.contains(st))
                    {
                        break;
                    }
                }
                else                    //Compare only the longest suffix
                {
                    if (rule.exceptions.getLongestSuffixValue(st) == true)
                    {
                        break;
                    }
                }
                if (st.Length >= suffix.Length + rule.size)
                {
                    return(st.Substring(0, st.Length - suffix.Length) + rule.replacement);
                }
            }
            return(st);
        }
示例#3
0
        private String applyRules(String st, SuffixTree<SavoyRule> rules)
        {
            int length = st.Length-1;
            if(length < rules.Properties["size"])	//If the word is smaller than the minimum stemming size of this step, ignore it
                return st;

            List<Pair<String, SavoyRule>> res = rules.getLongestSuffixesAndValues(st);
            for(int i=res.Count-1; i>=0; i--)
            {
                Pair<String, SavoyRule> r = res[i];
                String suffix = r.First;
                SavoyRule rule = r.Second;
                if(length > rule.size)
                    return st.Substring(0, st.Length-suffix.Length)+rule.replacement;
            }
            return st;
        }