コード例 #1
0
        /**
         * Create a CommonGramsFilter and wrap it with a CommonGramsQueryFilter
         */
        public override TokenStream create(TokenStream input)
        {
            CommonGramsFilter commonGrams = new CommonGramsFilter(input, commonWords,
                                                                  ignoreCase);
            CommonGramsQueryFilter commonGramsQuery = new CommonGramsQueryFilter(
                commonGrams);

            return(commonGramsQuery);
        }
コード例 #2
0
        public void inform(ResourceLoader loader)
        {
            string commonWordFiles = (string)args.get("words");

            ignoreCase = getBoolean("ignoreCase", false);

            if (commonWordFiles != null)
            {
                try {
                    List /*<String>*/ files = StrUtils.splitFileNames(commonWordFiles);
                    if (commonWords == null && files.size() > 0)
                    {
                        // default stopwords list has 35 or so words, but maybe don't make it
                        // that big to start
                        commonWords = new CharArraySet(files.size() * 10, ignoreCase);
                    }
                    for (var iter = files.iterator(); iter.hasNext();)
                    {
                        string            file  = (string)iter.next();
                        List /*<String>*/ wlist = loader.getLines(file.Trim());
                        // TODO: once StopFilter.makeStopSet(List) method is available, switch
                        // to using that so we can avoid a toArray() call
                        commonWords.addAll(CommonGramsFilter.makeCommonSet((string[])wlist
                                                                           .toArray(new string[0]), ignoreCase));
                    }
                } catch (IOException e) {
                    throw new System.ApplicationException("Unexpected exception", e);
                }
            }
            else
            {
#pragma warning disable 612
                commonWords = CommonGramsFilter.makeCommonSet(
                    StopAnalyzer.ENGLISH_STOP_WORDS, ignoreCase);
#pragma warning restore 612
            }
        }
コード例 #3
0
        /**
         * Constructor
         *
         * @param input must be a CommonGramsFilter!
         *
         */

        public CommonGramsQueryFilter(CommonGramsFilter input) : base(input)
        {
            prev = new Token();
        }