Ejemplo n.º 1
0
 public virtual void Inform(IResourceLoader loader)
 {
     if (resourceName == null)
     {
         // Get the dictionary lazily, does not hold up memory.
         this.dictionary = new PolishStemmer().Dictionary;
     }
     else
     {
         using Stream dict = loader.OpenResource(resourceName);
         using Stream meta = loader.OpenResource(DictionaryMetadata.GetExpectedMetadataFileName(resourceName));
         this.dictionary   = Dictionary.Read(dict, meta);
     }
 }
Ejemplo n.º 2
0
 private static Dictionary GetDictionary()
 {
     try
     {
         Type type = typeof(UkrainianMorfologikAnalyzer);
         // LUCENENET NOTE: In Lucene, this was downloaded from Maven as a dependency
         // (see https://search.maven.org/search?q=a:morfologik-ukrainian-search). However, we are embedding the file in .NET.
         // Since it doesn't appear to be updated frequently, this should be okay.
         string dictFile = "ukrainian.dict";
         using var dictStream     = type.FindAndGetManifestResourceStream(dictFile);
         using var metadataStream = type.FindAndGetManifestResourceStream(DictionaryMetadata.GetExpectedMetadataFileName(dictFile));
         return(Dictionary.Read(dictStream, metadataStream));
     }
     catch (IOException e)
     {
         throw new Exception(e.ToString(), e);
     }
 }
Ejemplo n.º 3
0
        private static Dictionary LoadDictionary()
        {
            Type type = typeof(PolishStemmer);

            lock (type)
            {
                string dict = ResourcePath + DictionaryName;
                using (var dictStream = type.Assembly.GetManifestResourceStream(dict))
                    using (var metadataStream = type.Assembly.GetManifestResourceStream(DictionaryMetadata.GetExpectedMetadataFileName(dict)))
                    {
                        if (dictStream == null)
                        {
                            throw new IOException("Polish dictionary resource not found.");
                        }

                        return(Dictionary.Read(dictStream, metadataStream));
                    }
            }
        }