Пример #1
0
        //JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        //ORIGINAL LINE: static void init(boolean ignoreCase, String affix, String... dictionaries) throws java.io.IOException, java.text.ParseException
        internal static void init(bool ignoreCase, string affix, params string[] dictionaries)
        {
            if (dictionaries.Length == 0)
            {
              throw new System.ArgumentException("there must be at least one dictionary");
            }

            System.IO.Stream affixStream = typeof(StemmerTestBase).getResourceAsStream(affix);
            if (affixStream == null)
            {
              throw new FileNotFoundException("file not found: " + affix);
            }

            System.IO.Stream[] dictStreams = new System.IO.Stream[dictionaries.Length];
            for (int i = 0; i < dictionaries.Length; i++)
            {
              dictStreams[i] = typeof(StemmerTestBase).getResourceAsStream(dictionaries[i]);
              if (dictStreams[i] == null)
              {
            throw new FileNotFoundException("file not found: " + dictStreams[i]);
              }
            }

            try
            {
              Dictionary dictionary = new Dictionary(affixStream, Arrays.asList(dictStreams), ignoreCase);
              stemmer = new Stemmer(dictionary);
            }
            finally
            {
              IOUtils.closeWhileHandlingException(affixStream);
              IOUtils.closeWhileHandlingException(dictStreams);
            }
        }
Пример #2
0
 /// <summary>
 /// Creates a new HunspellStemFilter that will stem tokens from the given TokenStream using affix rules in the provided
 /// Dictionary
 /// </summary>
 /// <param name="input"> TokenStream whose tokens will be stemmed </param>
 /// <param name="dictionary"> HunspellDictionary containing the affix rules and words that will be used to stem the tokens </param>
 /// <param name="longestOnly"> true if only the longest term should be output. </param>
 public HunspellStemFilter(TokenStream input, Dictionary dictionary, bool dedup, bool longestOnly) : base(input)
 {
     this.dedup       = dedup && longestOnly == false; // don't waste time deduping if longestOnly is set
     this.stemmer     = new Stemmer(dictionary);
     this.longestOnly = longestOnly;
 }